Forum Moderators: phranque

Message Too Old, No Replies

Request exceeded the limit of 10 internal redirects

Please help!

         

velcrobots

9:13 pm on Oct 10, 2011 (gmt 0)

10+ Year Member



I'm seeing this repeatedly in my error log. Below is my htaccess content. Is something creating a loop?

Options -Indexes
Options +FollowSymLinks

RewriteEngine on

# RSS Redirects
RewriteCond %{QUERY_STRING} ^id=5$
RewriteRule ^index\.php$ /?q=latest-news/feed [L]
RewriteRule ^Business_Aviation.xml$ /?q=taxonomy/term/9/feed [L]
RewriteRule ^Air_Transport_and_cargo.xml$ /?q=taxonomy/term/6/feed [L]
RewriteRule ^Defense.xml$ /?q=taxonomy/term/13/feed [L]
RewriteRule ^Accidents_Safety_Security_and_Training.xml$ /?q=taxonomy/term/1/feed [L]
RewriteRule ^Airports_Heliports_and_FBOs.xml$ /?q=taxonomy/term/7/feed [L]
RewriteRule ^Avionics_and_ATC.xml$ /?q=taxonomy/term/8/feed [L]
RewriteRule ^Cabin_Interior_and_Electronic.xml$ /?q=taxonomy/term/11/feed [L]
RewriteRule ^Charter_and_Fractional.xml$ /?q=taxonomy/term/12/feed [L]
RewriteRule ^Financing_Insurance_and_Taxes.xml$ /?q=taxonomy/term/14/feed [L]
RewriteRule ^General_Aviation.xml$ /?q=taxonomy/term/15/feed [L]
RewriteRule ^Maintenance_and_Modifications.xml$ /?q=taxonomy/term/16/feed [L]
RewriteRule ^People.xml$ /?q=taxonomy/term/17/feed [L]
RewriteRule ^Regulations_and_Government.xml$ /?q=taxonomy/term/19/feed [L]
RewriteRule ^Rotorcraft.xml$ /?q=taxonomy/term/21/feed [L]

# Other redirects
RewriteRule ^news/single-news-page/article/bolen-touts-gas-positive-trade-balance-for-us-31234/$ /?q=node/31234 [L]

# stuff to let through (ignore)
RewriteCond %{REQUEST_URI} "/openx/" [OR]
RewriteCond %{REQUEST_URI} "/typo3/" [OR]
RewriteCond %{REQUEST_URI} "/oa/"
RewriteRule (.*) $1 [L]

# Redirect all user to WWW
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# Serve Drupal from sub directory in web root
RewriteRule ^$ drupal/index.php [L]
RewriteCond %{DOCUMENT_ROOT}/drupal%{REQUEST_URI} -f
RewriteRule .* drupal/$0 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* drupal/index.php?q=$0 [QSA]

g1smd

9:38 pm on Oct 10, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



More than likely. The code is a mess.

It breaks many of the accepted conventions for organising and coding this stuff.

Give me a while and I'll cut and paste the stuff I have posted several thousand times already.

lucy24

9:53 pm on Oct 10, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Overlapping g1, so let's see how many times we wildly contradict each other ;)

Is something creating a loop?

That was a rhetorical question, wasn't it? Apache is not generally known to serve up error messages just because it's bored. (With the possible exception of the imaginary timeout error in a recent thread.)

# explanatory comments are good. But it will help a lot to do another thing: leave a blank line after each RewriteRule so you can tell them apart at a glance. This is especially important in places like your first block of rules, where the very first rewrite has a Condition, while all the following Rules are universal (no RewriteCond, just matching).

Matter of fact, that first block looks awfully familiar. I kinda think you are Rewriting a string of requests that need to be Redirected instead, and then the subsequent Rewrite is missing.

The "ignore" group can be written simply as the conditionless rule

RewriteRule ^(openx|typo3|oa)/ $1/ [L]

where the trailing slash is just to protect against longer requests that might happen to contain the letter sequence "oa". If those aren't top-level directories, make it

^(([^/]+/)+(openx|typo3|oa)/) $1 [L]

Note how the added parentheses sucked in the last slash so it can be included in the capture.

g1smd

9:59 pm on Oct 10, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



The comment
# RSS Redirects
is followed by a long list of rewrites, not redirects.

Do you want redirects or rewrites for these rules? Both use RewriteRule code, but with slightly different syntax.

If they are supposed to be rewrites, then they MUST be listed after your non-www to www redirect otherwise the previously rewritten path will be exposed as a URL when a non-www URL is requested and redirected to www.

Likewise the code directly after the
# Other redirects
comment is also an internal rewrite, not an external redirect. Is it meant to be?

Additionally, "slash" is not a valid character within a query string. You are asking for trouble here.

velcrobots

10:30 pm on Oct 10, 2011 (gmt 0)

10+ Year Member



I'm confused. I apologize. This is not my thing. I appreciate the time you guys all put into answering people like me.

The RSS entries could probably be redirects, hell, I don't know. We have an iPhone app (yes, if this sounds familiar you guys helped me a month or so ago) that is hard-coded to a certain set of rss feeds, and those links needed to still work with the newer system's rss feeds. So yeah, I guess they can be redirects.

The other redirect needs to be an external, I guess. Actually I'm going to remove it - it was a very popular story that was getting a lot of circulation right after we went live with the new system.

g1smd

11:11 pm on Oct 10, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Sorting out which requests need to be rewritten and which redirected is a fundamental decision.

Are you completely clear on the difference between a redirect (using a RewriteRule) and a rewrite (using a RewriteRule)?

velcrobots

12:09 am on Oct 11, 2011 (gmt 0)

10+ Year Member



A redirect using RewriteRule? I thought redirects used Redirect.

Jeez. Well there's your answer. A resounding no.

g1smd

12:16 am on Oct 11, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Redirects can be performed using Redirect or RedirectMatch or RewriteRule.

Rewrites can be performed only with RewriteRule (DirectoryIndex is a special type of rewrite too).

When using a RewriteRule, there are two common configurations for the rule:
  • target contains only a filepath (no domain name) and the rule has only the [L] flag - this is a rewrite
  • target contains protocol and domain name and the rule uses the [R=301,L] flags - this is a redirect.

    Redirects should always be listed before rewrites.

    If you use RewriteRule for rewriting, do not use Redirect or RedirectMatch anywhere in the same site configuration - use RewriteRule for all of your redirects and for all of your rewrites.
  •