Actions
Defect #4538
closed.htaccess redirect rules not working when multiple CGI/FastCGI modules enabled
Status:
Closed
Priority:
Normal
Assignee:
-
Category:
Permissions and roles
Target version:
-
Start date:
2010-01-08
Due date:
% Done:
0%
Estimated time:
Resolution:
Wont fix
Affected version:
Description
I just noticed something strange, using the default .htaccess file, when both mod_cgi and mod_fcgid were enabled. These are the default rewrite rules:
RewriteRule ^$ index.html [QSA] RewriteRule ^([^.]+)$ $1.html [QSA] RewriteCond %{REQUEST_FILENAME} !-f <IfModule mod_fastcgi.c> RewriteRule ^(.*)$ dispatch.fcgi [QSA,L] </IfModule> <IfModule mod_fcgid.c> RewriteRule ^(.*)$ dispatch.fcgi [QSA,L] </IfModule> <IfModule mod_cgi.c> RewriteRule ^(.*)$ dispatch.cgi [QSA,L] </IfModule>
With both mod_cgi and mod_fcgid, this translates to:
RewriteRule ^$ index.html [QSA] RewriteRule ^([^.]+)$ $1.html [QSA] RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ dispatch.fcgi [QSA,L] RewriteRule ^(.*)$ dispatch.cgi [QSA,L]
This means: non-static files are served through dispatch.fcgi (as expected), but when the RewriteCond doesn't match (i.e. it's a request for an existing static file) the request is sent through to the 2nd RewriteRule -- which ends you up with lots of CGI processes all not able to serve your images/CSS.
A better solution would be to use something like this, to make sure that only one RewriteRule can be active:
<IfModule mod_fastcgi.c> RewriteRule ^(.*)$ dispatch.fcgi [QSA,L] </IfModule> <IfModule !mod_fastcgi.c> <IfModule mod_fcgid.c> RewriteRule ^(.*)$ dispatch.fcgi [QSA,L] </IfModule> <IfModule !mod_fcgid.c> <IfModule mod_cgi.c> RewriteRule ^(.*)$ dispatch.cgi [QSA,L] </IfModule> </IfModule> </IfModule>
Updated by Etienne Massip over 13 years ago
- Category set to Permissions and roles
Actions