I'm creating a new .htaccess
file for my domain,
and I want to make sure that all parts of this code are valid, that the right flags are being used, that it would not create any conflicts, and whether the order of these command blocks is ok (is it important at all?)
Also, would you recommend any changes/additions?
# block direct access to folders
Options -Indexes
RewriteEngine on
# make non-www -> www
RewriteCond %{HTTP_HOST} ^(?!www\.)(.+) [NC]
RewriteRule ^(.*) http://www.%1/$1 [R=301,NE,L]
# block about 200 bad agents, and avoid an http 500 error with ENV at first
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{HTTP_USER_AGENT} ^(badbot1|badbot2|....up-to-badbot200) [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^$
RewriteRule ^.* - [F,L]
# several types of url rewriting to nice looking urls (about 30)
RewriteRule ^vegetables/healthy-carrot/?$ carrot.php [L]
RewriteRule ^vegetables/delicious-tomato/?$ tomato.php [L]
RewriteRule ^vegetables/great-avocado/?$ avocado.php [L]
RewriteRule ^fruits/nice-apple/?$ apple.php [L]
RewriteRule ^fruits/best-strawberry/?$ strawberry.php [L]
RewriteRule ^sitemap/?$ sitemap.php [L]
RewriteRule ^contact-us/?$ contact.php [L]
RewriteRule ^privacy-policy/?$ privacy.php [L]
RewriteRule ^general/action/?$ /general/process.php [L]
# use cache for images to make site load faster
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType image/jpg "access plus 1 month"
</IfModule>
Thanks!