LimitInternalRecursion, .htaccess and rewritting e
Posted by: Moonwalker
Posted on: 2009-03-17 11:10:00
Hello everyone,
I am creating my first application based on Zend Framework. I have managed to create my own version of php.ini, I have included my library paths, and created a folder structure as follows:
domain
\__cgi-bin
\__data
\__htdocs
\__include
\__Controllers
\__Smarty
\__Templater
\__templates
When I was first testing my own copy of php.ini, my domain was pointing to domain.com, so in order to execute my files I had to access domain.com/htdocs/index.php
In the htdocs folder, I have this bootstrap file (.htaccess):
<IfModule mod_actions.c>
Options +ExecCGI
AddHandler php5-cgi .php
Action php-cgi /cgi-bin/php-wrapper.cgi
Action php5-cgi /cgi-bin/php-wrapper.cgi
</IfModule>
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^/cgi-bin/.*$ - [PT]
RewriteCond $1 !^cgi-bin/.*$ [NC]
RewriteCond %{REQUEST_URI} ^/(stats/|missing\.html|failed_auth\.html|error/).* [NC]
RewriteRule .* - [L]
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1
RewriteCond %{ENV:REDIRECT_STATUS} 200
RewriteRule .* - [L]
</IfModule>
Initially it was only
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1
Because as many of you know, when using Zend Framework, all requests have to go through htdocs/index.php.
Well it worked fine until I changed my domain settings using Dreamhost's Control Panel. I changed my domain to point to the domain.com/htdocs folder, because I want that folder to be the "root" of the domain.
But since I did that change I get this error:
500 Internal Server Error
If I see the logs, I read:
[Tue Mar 17 10:52:08 2009] [error] [client 80.25.201.118] 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.
[Tue Mar 17 10:52:08 2009] [error] [client 80.25.201.118] 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.
[Tue Mar 17 10:52:09 2009] [error] [client 80.25.201.118] 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.
[Tue Mar 17 10:52:09 2009] [error] [client 80.25.201.118] 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.
I've spent hours trying to figure out what was happening. The solutions I've found are all included in the .htaccess I've pasted above.
I'll try to explain why I have included certain rules, and if anyone has any idea of what's wrong, please tell me.
These lines:
RewriteRule ^/cgi-bin/.*$ - [PT]
RewriteCond $1 !^cgi-bin/.*$ [NC]
are to avoid requests to my cgi folder being rewritten.
These ones are supposed to avoid infinite loops:
RewriteCond %{REQUEST_URI} ^/(stats/|missing\.html|failed_auth\.html|error/).* [NC]
RewriteRule .* - [L]
RewriteCond %{ENV:REDIRECT_STATUS} 200
RewriteRule .* - [L]
But they don't. One thing I've noticed is that depending on their order, I see 2 or 4 errors, so they definitely do something.
My guess is that by changing my domain settings to point to the domain.com/htdocs I am adding more redirections. Besides, I have also instructed the control panel to add www. if my visitors don't include it. So that adds even more complication.
I've read somewhere that I could raise the number of allowed redirections by editing httpd.conf, something that I'm not sure can be done in Dreamhost.
Has anyone experimented similar problems?
Any idea would be appreciated.
Thanks in advance!
<b>Luis</b>