Forum Moderators: phranque

Message Too Old, No Replies

Internal Server Errors

"Request exceeded the limit of 10 internal redirects..."

         

alexmel7

10:00 pm on Feb 3, 2011 (gmt 0)

10+ Year Member



Hello, I keep getting internal server errors on my site that go away when I refresh the page. When I checked my error log, it's just a continuous loop of messages similar to the following:

"[Thu Feb 03 07:54:28 2011] [error] [client 24.58.234.63] Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace., referer: [community.rust2green.org...]

Now, I am by no means an expert on any of these topics, but based on something I found in this forum, I gather this error has to do with a rewrite condition looping. I would appreciate if anyone could help me solve this (understanding that I am definitely not a developer). Here are the contents of my .htaccess file:


# $Id: .htaccess 7539 2010-10-04 04:41:38Z john $
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
# Get rid of index.php
RewriteCond %{REQUEST_URI} /index\.php
RewriteRule (.*) index.php?rewrite=2 [L,QSA]
# Rewrite all directory-looking urls
RewriteCond %{REQUEST_URI} /$
RewriteRule (.*) index.php?rewrite=1 [L,QSA]
# Try to route missing files
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} public\/ [OR]
RewriteCond %{REQUEST_FILENAME} \.(jpg|gif|png|ico|flv|htm|html|php|css|js)$
RewriteRule . - [L]

# If the file doesn't exist, rewrite to index
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?rewrite=1 [L,QSA]
</IfModule>
# sends requests /index.php/path/to/module/ to "index.php"
# AcceptPathInfo On
# @todo This may not be effective in some cases
FileETag Size

g1smd

11:27 pm on Feb 3, 2011 (gmt 0)

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



index.php matches the first pattern and is rewritten to index.php + some parameters.

The rewritten index.php matches the first pattern and is rewritten to index.php + some parameters.

The rewritten index.php matches the first pattern and is rewritten to index.php + some parameters.

... and over again until the server gives up.

You need to test THE_REQUEST, not REQUEST_URI, in at least the first two rules.

g1smd

11:30 pm on Feb 3, 2011 (gmt 0)

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



Where you have a rule that includes -f or -d "exists" checks, make sure the OTHER RewriteConds are listed FIRST.

If the -f and -d checks appear first, your server hard drive will be surely and rapidly beaten to death as it has to be accessed multiple times per URL request even before starting to actually fetch any content. Those accesses are also very inefficient, and very slow.

alexmel7

2:08 pm on Feb 4, 2011 (gmt 0)

10+ Year Member



Thanks for the reply g1smd. So this is probably completely wrong, but is this what I want to do:

# $Id: .htaccess 7539 2010-10-04 04:41:38Z john $
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
# Get rid of index.php
RewriteCond %{THE_REQUEST} /index\.php
RewriteRule (.*) index.php?rewrite=2 [L,QSA]
# Rewrite all directory-looking urls
RewriteCond %{THE_REQUEST} /$
RewriteRule (.*) index.php?rewrite=1 [L,QSA]
# Try to route missing files
RewriteCond %{REQUEST_FILENAME} public\/ [OR]
RewriteCond %{REQUEST_FILENAME} \.
RewriteCond %{REQUEST_FILENAME} !-f
(jpg|gif|png|ico|flv|htm|html|php|css|js)$
RewriteRule . - [L]

# If the file doesn't exist, rewrite to index
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?rewrite=1 [L,QSA]
</IfModule>
# sends requests /index.php/path/to/module/ to "index.php"
# AcceptPathInfo On
# @todo This may not be effective in some cases
FileETag Size

g1smd

7:30 pm on Feb 4, 2011 (gmt 0)

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



That's the gist of it, but the value of THE_REQUEST will be something like:
GET /path HTTP/1.1
GET / HTTP/1.1

and so on.

You'll need a pattern like
[A-Z]{3,9}\ /path\ HTTP/

where "\ " matches a literal space and "/" is a slash.