.htaccess mod_rewrite 500 internal server error due to too many internal redirects from LimitInternalRecursion
8,233
Change your code with this:
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]
Related videos on Youtube
Author by
Stephen Ostermiller
Updated on September 18, 2022Comments
-
Stephen Ostermiller over 1 year
Whenever I place my .htaccess file in my web directory I receive a 500 internal server error and within the error.log file specifying:
[Sat Jan 21 13:46:07 2012] [error] [client xx.xx.xxx.xx] 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.
My .htaccess file:
RewriteEngine On RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !(\.png|\.jpg|\.gif|\.jpeg|\.bmp|\.css|\.js)$ RewriteRule ^(.*) index.php
I have tried enabling Options +FollowSymLinks but this has been fruitless.
Everything works locally. Any pointers as to what I could be doing wrong?
-
Admin about 12 yearsYou can't use two %{} parameters in a single RewriteCond.. use REQUEST_URI for your rule above
-
Admin about 12 yearsthis is not true, you can use multiple %{} parameters, this will look for the regex in the concatenated string
-
Admin about 12 years@yoavmatchulsky בכיף :)
-
-
Admin about 12 yearsThat will check if the URL doesn't exists.. that's not what he asked for..
-
Admin about 12 yearsalso, if you want to check the -f flag, you need to check it against the full path of the file, just the REQUEST_FILENAME will always return false
-
Admin about 12 yearsThis seems quite logical, however it does not solve the problem. Thanks for your help anyway.
-
Admin about 12 yearsThe error log now says [Sat Jan 21 15:40:40 2012] [alert] [client xx.xx.xxx.xx] /home/sites/xxx/subdomains/xxx/.htaccess: RewriteCond: bad flag delimiters
-
anubhava about 12 years@yoavmatchulsky: That's not correct, please read Apache docs again. It will only check if requested file exists then don't apply the rule.
-
Admin about 12 years@BartZweers I had an extra space in my expression, but fixed it above. Try the edited version. Also, confirm that you do not have any other rules in this, or other .htaccess files.
-
anubhava about 12 years@YaronUliel: Go and read some Apache documentation before reaching to conclusion like this. REQUEST_FILENAME is indeed the full path of the requested file not just the base file name. And even though OP showed images in his example eventually that rule will be needed to avoid redirection for all static files like images, css, js etc. That's why it is important to avoid it like this.
-
Admin about 12 years@anubhava tnx for your reply - I confused between REQUEST_FILENAME, and REQUEST_URI. my mistake
-
Admin about 12 years@anubhava I removed the first line. It works perfectly now. Thanks a lot!
-
anubhava about 12 yearsYou're welcome, glad that it worked out. I think this is my accepted answer with a negative vote :) ... not sure why the down-voter did so though.