Reputation: 1
I'm running an Apache 2.2.19 server and I'm having an issue with mod_rewrite when dealing with the .html extension. The .php URL cleaning works fine, but not .html. In the error logs, I get this:
[Fri Aug 12 04:17:36 2011] [error] [client (AN IP ADDRESS)] script '(A DIRECTORY PATH)/forbidden.php' not found or unable to stat, referer: (MY WEBSITE)
[Fri Aug 12 04:17:38 2011] [error] [client (AN IP ADDRESS)] script '(A DIRECTORY PATH)/notfound.php' not found or unable to stat, referer: (MY WEBSITE)
where some information is omitted for security and privacy reasons (which is replaced by text in parentheses). forbidden and notfound are actually HTML files with an HTML extension, but for some reason, mod_rewrite is attempting to access .php files. Without the easy fix of just changing the file extensions to .php, how can I get mod_rewrite to look at the proper extension and evaluate that, rather than looking at HTML files as having a .php extension??
Thanks a lot in advance!
Here's the related code, which is in httpd.conf:
RewriteEngine on
Options +FollowSymlinks
RewriteCond %{REQUEST_URI} !(\.[^./]+)$
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} \.html-f
RewriteRule (.*) /$1.html [L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^.]+\.)+html\ HTTP
RewriteRule ^([^\.]+)\. $1 [R=302,L]
RewriteCond %{REQUEST_FILENAME} \.php-f
RewriteCond %{REQUEST_FILENAME} phpinfo
RewriteRule (.*) /$1.php [L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^.]+\.)+php\ HTTP
RewriteRule ^([^\.]+)\. $1 [R=302,L]
Upvotes: 0
Views: 604
Reputation: 26749
The rule for .html files have 2 additional conditions:
RewriteCond %{REQUEST_URI} !(\.[^./]+)$
RewriteCond %{REQUEST_FILENAME} !-d
I think the first one is causing the problem, 'cause you are looking for .html in the filename, but the uri should not contain .
Upvotes: 1