Forum Moderators: phranque

Message Too Old, No Replies

Request exceeded the limit of 10 internal redirects due to probab$

         

jake66

6:59 am on Jul 6, 2008 (gmt 0)

10+ Year Member



Last week I upgraded to Apache 2 and now I see these errors in my logs:
[Sun Jul 06 00:00:50 2008] [error] [client xx.xx.202.234] Request exceeded the limit of 10 internal redirects due to probab$

Searching around the web this seems to relate to rewrite rules? Could somebody be so kind to check mine and see what's triggering this?

RewriteEngine on
RewriteBase /

RewriteCond %{REQUEST_METHOD} ^TRACE
RewriteRule .* - [F]

RewriteRule ^([^/]*)\.html$ $1.php?%{QUERY_STRING} [NC]
#new rule below
#RewriteRule ^brand/([^/]+)/page([0-9]+)\.html$ index.php?manufacturers_id=$1&page=$2 [L]
RewriteRule ^brands/([^.]+)\.html$ brands.php?letternum=$1&%{QUERY_STRING} [NC,L]
RewriteRule ^brand/([^.]+)\.html$ index.php?manufacturers_id=$1&%{QUERY_STRING} [NC,L]
RewriteRule ^brands/([^.]+)\.html$ brands.php?letternum=$1&%{QUERY_STRING} [NC,L]
RewriteRule ^product/([^.]+)\.html$ product_info.php?products_id=$1&%{QUERY_STRING} [NC,L]
#RewriteRule ^category/([^.]+)/page([0-9]+)\.html$ index.php?cPath=$1&%{QUERY_STRING}&page=$2 [NC,L]
RewriteRule ^category/([^.]+)\.html$ index.php?cPath=$1&%{QUERY_STRING} [NC,L]
RewriteRule ^offer/([^.]+)\.html$ offer.php?products_id=$1&%{QUERY_STRING} [NC,L]
RewriteRule ^type/([^.]+)\.html$ type.php?type=$1&%{QUERY_STRING} [NC,L]
RewriteRule ^new/([^.]+)\.html$ brand_newbrands.php?type=$1&%{QUERY_STRING} [NC,L]

g1smd

4:44 pm on Jul 6, 2008 (gmt 0)

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



You can diagnose this quite easily.

You need a copy of Mozilla Firefox and you need to add the Live HTTP Headers extension to it.

Once done, start the extension and then attempt to access a page on your site.

Look at the Headers window and see that you get redirected to another URL and then redirected to another URL and then redirected to another URL and then redirected to another URL and then redirected to another URL and then redirected to another URL and so on.

The ordering of your rules is important. You should have the most specific first, and it should deliver you directly to the destination URL, not to another URL that is then the subject of another of your rules.

jake66

12:08 am on Jul 7, 2008 (gmt 0)

10+ Year Member



Hi,

It's only showing me the loading of the html info & every image on the page.. can't seem to spot anything going to several different URLs on one page.

jdMorgan

12:12 am on Jul 7, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It would be helpful to know what URL you're requesting to get the internal recursion.

From a quick overview, it appears that none of these rules will loop, because they all rewrite .html to .php. Unless you've got another rule somewhere that does the reverse, then this code is not at fault.

Jim

jake66

4:15 am on Jul 7, 2008 (gmt 0)

10+ Year Member



It would be helpful to know what URL you're requesting to get the internal recursion.

How do I find that out?

These are lower down in my htaccess, could these be it?


SetEnvIfNoCase User-Agent "Baiduspider" bad_bot
Order Allow,Deny
Allow from all
Deny from env=bad_bot

<Files 403.shtml>
order allow,deny
allow from all
</Files>
deny from amazonaws.com
deny from 210.224.177.

<Limit GET POST>
order allow,deny
allow from all
deny from ip address
deny from .af
</Limit>

<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>

ErrorDocument 404 /404.php
ErrorDocument 403 /403.shtml
ErrorDocument 401 /401.php

<Files *.ini>
Order Deny,Allow
Deny from all
</Files>
RewriteCond %{HTTPS_HOST} !^www\.mysite\.com
RewriteCond %{HTTP_HOST} !^www\.mysite\.com
RewriteRule (.*) [mysite.com...] [R=301,L]

RewriteCond %{HTTP_REFERER} (10.20.x.x) [NC,OR]
RewriteCond %{HTTP_REFERER} (10.166.x.x) [NC,OR]

RewriteCond %{HTTP_REFERER} .
RewriteCond %{HTTP_REFERER} !^http?://(www\.)?mysite\.com [NC]
RewriteCond %{HTTP_REFERER} !^https?://(www\.)?mysite\.com [NC]
RewriteRule \.(gif¦jpeg¦jpg¦bmp¦mp3)$ - [NC,F]

RewriteCond %{HTTP_REFERER} .
RewriteCond %{HTTP_REFERER} !^http?://(www\.)?mysite\.com [NC]
RewriteCond %{HTTP_REFERER} !^https?://(www\.)?mysite\.com [NC]
RewriteCond %{QUERY_STRING} &?img=[^&]+ [NC]
RewriteRule ^product_thumb\.php$ - [F]

g1smd

11:05 am on Jul 7, 2008 (gmt 0)

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



There's some inefficiencies there.

Additionally, https? tests for https and http
and http? tests for http and htt.

That's likely not what you wanted.

I expect that

RewriteCond %{HTTP_REFERER} !^https?://(www\.)?mysite\.com [NC]

is all you need there.

jdMorgan

3:33 pm on Jul 7, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It would be helpful to know what URL you're requesting to get the internal recursion.

How do I find that out?


The usual way is to read the URL you typed in the address bar...

The only thing I see wrong in here is this:


RewriteCond %{HTTPS_HOST} !^www\.mysite\.com

Since there is no such variable as "HTTPS_HOST" the value will always be blank, and since the pattern is a negative-match it will always match, so the redirect will always be invoked and create a loop.\

Jim

jake66

6:00 am on Jul 8, 2008 (gmt 0)

10+ Year Member



Thanks very much guys, I removed both of those lines and I will keep an eye on my logs to see if the errors go away.

jdMorgan

12:58 pm on Jul 8, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Both of those lines? Only the single line with %{HTTPS_HOST} is invalid.

It's not clear which two lines you're referring to, but if you also remove the line with %{HTTP_HOST}, I'm afraid you'll be right back to looping...

Jim

g1smd

12:59 pm on Jul 8, 2008 (gmt 0)

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



Hopefully referring to the line I mentioned in my comment, the one testing for htt and http, when there was already one testing for http and https.

I hope the OP posts the new modified code here again, so we can check it.

jake66

5:55 am on Jul 11, 2008 (gmt 0)

10+ Year Member



jdMorgan,

I also had:

RewriteCond %{HTTP_REFERER} .
RewriteCond %{HTTP_REFERER} !^http?://(www\.)?mysite\.com [NC]
RewriteCond %{HTTP_REFERER} !^https?://(www\.)?mysite\.com [NC]
RewriteCond %{QUERY_STRING} &?img=[^&]+ [NC]
RewriteRule ^product_thumb\.php$ - [F]

I removed the line with:
RewriteCond %{HTTP_REFERER} !^http?://(www\.)?mysite\.com [NC]

As if I understand g1smd correctly, https? searches for both http & https.

To sum up, these are the two lines I removed:
RewriteCond %{HTTP_REFERER} !^http?://(www\.)?mysite\.com [NC]

RewriteCond %{HTTPS_HOST} !^www\.mysite\.com
RewriteCond %{HTTP_HOST} !^www\.mysite\.com
RewriteRule (.*) [mysite.com...] [R=301,L]

RewriteCond %{HTTP_REFERER} .
RewriteCond %{HTTP_REFERER} !^http?://(www\.)?mysite\.com [NC]
RewriteCond %{HTTP_REFERER} !^https?://(www\.)?mysite\.com [NC]
RewriteCond %{QUERY_STRING} &?img=[^&]+ [NC]
RewriteRule ^product_thumb\.php$ - [F]

I cleared my apache error logs.
Clicked a couple of pages, nothing. Waited a bit and spotted one.

I compared the visitor's IP to my access log.. their referral was Google images.

The only connection I noticed was this line from htaccess:
RewriteCond %{HTTP_REFERER} (images) [NC,OR]

..this is toward the bottom of my htaccess. Any idea what's wrong with this?

jdMorgan

4:52 am on Jul 16, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The only connection I noticed was this line from htaccess:
RewriteCond %{HTTP_REFERER} (images) [NC,OR]

What is the RewriteRule that follows this RewriteCond?

Jim