Magento – Magento/Apache internal redirects hang the server

magento-1.6magento-1.7magento-enterpriseoverridesredirect

I've asked a similar question on StackOverflow, but to no avail. Here is the issue I've been facing for the last few weeks:

Once in a while our Apache server hangs, to bring everything back up I'm forced to run service apache2 restart. Each time the server hangs I review Apache logs and I see the same thing:

[error] [client 66.249.75.233] 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.

This entry is repeated sometimes 10, 20, 30+ times all within 5-10 seconds of each other just before the server goes down and seems to randomly pop in throughout the day. I am almost certain this is what is causing Apache to hang. Now, the IP is from one of Googles Bots and I've tried literally everything I can think of to remedy the internal redirect without any luck 🙁

Here is what I've tried:

  • Used the default .htaccess files from a stock Magento EE 1.13
    installation. The log entries still show up in the log.
  • Tried running tail -f on error.log and rewrite.log with
    RewriteLogLevel 4 side-by-side to try and see if I can catch the internal redirect in the rewrite log. Nothing. I can see the new entries in the error.log, but there is absolutely nothing in the rewrite.log
  • Tried enabling LogLevel debug and grepping for the 66.249.75.233
    IP. Nothing.
  • Tried setting LimitInternalRecursion 3 in
    <VirtualHost>...</VirtualHost>. Again, the entry is logged saying Request exceeded the limit of 10 internal redirects...
  • Tried different .htaccess configurations such as:
    RewriteCond %{ENV:REDIRECT_STATUS} 100
    RewriteRule .* - [L]
  • Or setting: RewriteBase /. Still can't get rid of the error.
  • Even tried blocking the IP in Apache and in the server firewall. The entry still shows up WTF!!!

We are running a single domain website so I've combined all of Magentos .htaccess files into one (99% stock Magento .htaccess) and the only mod_rewrite directives are:

# Magento root directory
<IfModule mod_rewrite.c>
    Options +FollowSymLinks
    RewriteEngine on
    RewriteRule ^.*\.html$ /index.php [L] # I added this rewrite to skip all the other condition checks and push all *.html requests directly into index.php
    RewriteCond %{REQUEST_URI} !^/robots\.txt
    RewriteCond %{REQUEST_URI} !^/(media|skin|js|var)/
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-l
    RewriteRule .* index.php [L]
</IfModule>

and

# Magento media directory
<IfModule mod_rewrite.c>
    Options +FollowSymLinks
    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule .* /var/www/barebones_live/get.php [L]
</IfModule>

Worst of all, I can't replicate this error myself!

I am completely clueless as to how to track down this entry now and why it is occurring. ANY help or pointers would be greatly appreciated. Perhaps I can try an track this down through Magento, but where would I start? Hmm, maybe I can Mage::log() in the index controller for all URL requests and see how things go from there..?

Best Answer

If you are facing this problem, You have to commment the line in .htaccess file.

#    RewriteBase /magento/

or

Set the RewriteBase in .htaccess file.

RewriteBase /

I have tested this in Magento 2

Related Topic