2

I'm setting up a local environment via MAMP of a site that I took down off the web a couple of months back in order to view some old functions on the site, and I am currently receiving the following error in my apache_error.log file.

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: http://localhost:8888/

I have looked for solutions in other posts (e.g. Request exceeded the limit of 10 internal redirects due to probable configuration error), and I know it has to do with my .htaccess file. However, I have been unable to figure out what is wrong due to my file being rather specific. Here it is (I changed my website name to example.com for sake of privacy):

Options FollowSymlinks
RewriteEngine On
RewriteRule ^demo/ - [L]
RewriteRule ^\.htaccess$ - [F]
RewriteCond %{HTTP_HOST} ^example.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
RewriteCond %{REQUEST_URI} =""
RewriteRule ^.*$ example/public/index.php [NC,L]
RewriteCond %{REQUEST_URI} !^/public/.*$
RewriteRule ^(.*)$ example/public/$1
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^.*$ - [NC,L]
RewriteRule ^public/.*$ example/public/index.php [NC,L]

This might be a longshot, but if anyone can take a look and offer an idea of what might be causing the error, I'd be forever grateful.

Community
  • 1
  • 1
jaewo0k
  • 245
  • 1
  • 3
  • 6

1 Answers1

0

I've encountered this with a lot of RewriteRules in my .htaccess file. The most straightforward thing to do is to add a line in the .conf file for that domain/site to increase the limit, as 10 is a bit tight. Use LimitInternalRecursion followed by a higher number.

For example, I have two sites they have:

LimitInternalRecursion 100 (one site with a lot of blocking rules)

LimitInternalRecursion 500 (an ajax-heavy SSL site with a lot of redirects to force things to do https instead of http)

A good rule of thumb is the more RewiteRules the higher the number, especially if your RewriteRules are doing a lot of blocking.

If you're still looking to trim your RewritesRules down, I'd go with (for Apache 2.2):

<FilesMatch "\.(htaccess|htpasswd|ini|phps|psd|log|sh|eye)$"> Order Allow,Deny Deny from all </FilesMatch>

(Require all denied for Apache 2.4)

instead of RewriteRule ^\.htaccess$ - [F] to protect .htaccess and other files (e.g. .ini, .log, .psd, .sh, .eye, etc.). This gives you more flexibility to block additional files.

UPDATE:

While reading Apache docs today for something else, I learned that LimitInternalRecursion will take two number values, the first number for the maximum number of redirects, the second for "how deeply subrequests may be nested" (read up on LimitInternalRecursion), something like:

LimitInternalRecursion 100 20

will better tune the directive.

With only one number present, Apache assumes that number for both values, so:

LimitInternalRecursion 500

will be read by Apache as:

LimitInternalRecursion 500 500

which is a little extreme ...

mr.cook
  • 101
  • 2