11

When I call our sit "www.example.com/contact-us" I'm getting the following error:

Oops, looks like this request tried to create an infinite loop. We do not allow such things here. We are a professional website!

If I call the site with "www.example.com/node/5" the contact page is displayed just fine.

When I check the path alias on /admin/config/search/path/edit/6, system path and alias are set correctly.

Another problem exists for another alias, when I call "www.example.com/staff" I'm getting redirected to the landing page "www.example.com". Once again the alias is set correctly.

We're using Drupal 7, and the i18n_redirect and redirect modules.

  • I guess I found it: in "www.example.com/admin/config/search/redirect" there were entries redirecting those URL's. I don't know how they got there though ... – Matthias Jan 4 '13 at 12:52
19

Edit your page and go to URL redirects. Find the redirect path with the most number of count and delete it. Click save then view the page.

Let me know if that fixed your problem

  • I'm having a similar issue and while this fixes things for individual nodes I'm trying to figure out what causes it in the first place so this doesn't occure to start with. – Gold May 26 '13 at 20:08
8

Update: Drupal issue #1796596 was committed as of Redirect 1.0-rc2 (June 2015). The correct solution for this problem now is to upgrade to the latest stable release of Redirect module, and then run database updates. Any circular redirects you have will be safely cleaned up.

This issue came about due to a bug in the redirect module. You trigger it by changing a page's URL (or maybe just its title, if you're using pathauto) and then changing it back to what it used to be.

For example, let's say I had a page called "company" and I changed the title to "Our company" (which changed the URL alias to our-company). Then I decided I actually preferred it the first way soI edit the node again and change the title back to "Company". At that point the error message "Oops, looks like this request tried to create an infinite loop. We do not allow such things here. We are a professional website!" would start showing up on the Company page.

There are three ways to fix this, depending on what's easiest for you. They range in difficulty/bravery from top to bottom.

The Drupal/PHP method

There's a long Drupal bug on the subject: Issue #1796596 and there is a good working patch that fixes the issue in comment #124.

Hopefully this fix will soon get committed into the Redirect module up for download. However it's been over a year now with no sign of any progress on that front.

The SQL method

The fastest fix for the problem is with a SQL query to the database, with something like below. BE CAREFUL and only try this method if you know what you're doing - try it on a development copy of the site first and make sure you have a backup and test the changes right afterwards in case you need to roll back. Be extra careful and test the first query extra well if you are using i18n... Run the first query to show what would be deleted and the second to actually do the delete.

--Show records to be deleted:
SELECT r.rid, r.language, r.source, r.redirect
  FROM redirect r INNER JOIN url_alias u ON r.source = u.alias
         AND r.redirect = u.source AND r.language = u.language;

--Delete redirects shown in above query:    
DELETE r FROM redirect r INNER JOIN url_alias u ON r.source = u.alias
         AND r.redirect = u.source AND r.language = u.language;

If you do not know how to apply patches or run SQL queries, then you need to fix the problem manually. Don't worry, this is actually quite easy to do (but time consuming compared to the other methods):

The Manual Method:

For each of the pages where the warning message displayed:

  1. Edit the page
  2. Scroll to the bottom of the edit form
  3. Note the main URL of the page. It's shown underneath "URL path settings", e.g. "Alias: company" would mean the URL of the page is "company". You can click on the "URL Path Settings" to visit its section and confirm the URL alias if you're not sure.
  4. Now click "URL redirects". The redirects to the current page will be shown. There will be at least one redirect that is the same as the URL alias you noted in step 3. It's possible more than one redirect in this list will match the URL alias.
  5. Delete all redirects that are the same as the URL alias. These are the problem data that are causing the loop and the error message to be displayed.
  6. Once there are no more redirects under "URL redirects" that exactly match the problem page's URL alias under URL path settings, the error message will be gone.
  • good working SQL method ! thx – rémy Mar 22 '14 at 22:50
  • The patch to redirect is very nearly ready for release. Just thought I'd mention it. – Alfred Armstrong Feb 10 '15 at 10:37
1

If we have the same redirecs to node's alias, another way to fix this error is to run a script that through all the nid (in case of nodes) and see if the alias of each node has a redirection with the same name, if any is eliminated.

for ($i=1; $i<=10000; $i++) {
  $alias = drupal_get_path_alias("node/" . $i);
  $redirect = redirect_load_by_source($alias);
  if ($redireccion->rid> 0) {
    redirect_page_cache_clear($redirect);
    redirect_delete($redireccion->rid);
  }
}

You can run this code in the option "Execute PHP Code" from development menu.

This form is similar to "The SQL method" just I execute this from Drupal and not on database.

  • This worked perfectly! – albertski May 21 '15 at 14:06
0

Apply the patch over at Fix and prevent circular redirects (or wait until it makes it into the module).

0

Create Drush script:

<?php
// Set up the query using the database API
$query = db_select('redirect', 'r');
$query->join('url_alias', 'ua', 'r.redirect = ua.source AND r.source = ua.alias');
$query->fields('r', array('rid', 'redirect', 'source'));

// Execute it and fetch the results, one by one
$result = $query->execute();
$any_results = FALSE;
while($r = $result->fetchAssoc()) {
  // For each result, flag we've got at least one result, notify the CLI user
  // of what we're doing, and delete it using Redirect's own API
  $any_results = TRUE;
  drush_log(dt("Deleting unwanted redirect !r (!s -> !t)",
    array("!r" => $r['rid'], "!s" => $r['source'], "!t" => $r['redirect'])), "success");
  redirect_delete($r['rid']);
}

// No results? Report if that's the case
if (!$any_results) {
  drush_log(dt("Nothing to delete!"), "ok");
}

Save it to a file and run it from within your site's codebase using drush php-script [PATH_TO_SCRIPT], and it will delete any redirects which clash with the URL aliases.

0

How can I prevent displaying the "redirect loop" error message in production server in future? I have already set error reporting "none" in this page - admin/config/development/logging

-2

The only way after trying many patched was to open the redirect.module file and omit line #989

drupal_set_message('Oops, looks like this request tried to create an infinite loop. We do not allow such things here. We are a professional website!');
  • 1
    So instead of fixing the infinite redirect loop you just omitted the warning? – George Feb 6 '14 at 3:47
  • 1
    Although I did this sort of thing when I was a child (before I knew how to code), I don't recommend doing this in any professional capacity. Not only are you not solving the problem, you're hiding the only indicator that something is wrong! – colan Feb 25 '14 at 20:52
-2

My english is no very good, but I think you do not problem read me. I have before that problem and I solved it so I removed the module REDIRECT. Regards KoZnaZna site Team - Simon

  • 1
    Removing the Redirect module will not help you if you require its features. – colan Feb 25 '14 at 20:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.