Forum Moderators: phranque

Message Too Old, No Replies

FilesMatch and Rewrites

         

Steven Davis

6:24 pm on Jun 29, 2011 (gmt 0)

10+ Year Member



Everything in the following .htaccess file worked fine until I added the

<FilesMatch "\.(ico|jpg|jpeg|png|gif|js|css|swf)$">
ExpiresActive on
ExpiresDefault "access plus 7 days"
Header unset ETag
FileETag None
</FilesMatch>

to the bottom to control the cache. Now I get and Internal Server Error any idea why? Here is the entire non-working .htaccess file:

Options +FollowSymLinks -MultiViews
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?example\.com/ [NC]
RewriteRule .*\.(jpe?g|gif|bmp|png)$ - [F]

RewriteCond %{THE_REQUEST} ^GET\ /([^/]+/)*[^.]+\.php(\?[^\ ]*)?\ HTTP/
RewriteRule ^(([^/]+/)*[^.]+)\.php$ http://www.example.com/$1 [R=301,L]

RewriteCond %{REQUEST_URI} ^(.*)//(.*)$
RewriteRule . %1/%2 [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ http://www.example.com/$1 [R=301,L]

RewriteCond %{HTTP_HOST} !^www.example.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]

RewriteCond $1 !\.(gif|jpe?g|png|bmp|ico|css|js)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ /$1.php [L]

ErrorDocument 404 /404.html
ErrorDocument 500 /500.html

<FilesMatch "\.(ico|jpg|jpeg|png|gif|js|css|swf)$">
ExpiresActive on
ExpiresDefault "access plus 7 days"
Header unset ETag
FileETag None
</FilesMatch>

g1smd

6:39 pm on Jun 29, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You need to add the domain name to the rule target in the double-slash/single-slash rule.

You need to make sure that mod_expires has actually been activated on the server.

RewriteCond %{HTTP_HOST} !^www.example.com$ [NC]
should be:
RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$
with SIX changes to that one line.

Steven Davis

6:53 pm on Jun 29, 2011 (gmt 0)

10+ Year Member



Thank you I just found out my host GoDaddy does not support the mod-expires module on their Grid Hosting solution.