Forum Moderators: phranque
ErrorDocument 404 /404.html
ErrorDocument 403 /403.html
Options All -Indexes
#
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
#
# move ancient but still requested file to current location
rewriterule ^folder/oldfile\.htm$ http://www.example.com/folder/ [R=301,L]
#
# redirect index.html to folder
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(([^/]+/)*)index\.html\ HTTP/
RewriteRule index\.html$ http://www.example.com/%1 [R=301,L]
#
# add the www if missing
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST}!^www\.example\.com
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
#
# block a few bad guys
SetEnvIfNoCase User-Agent "^Wget" bad_bot
SetEnvIfNoCase User-Agent "SiteSucker" bad_bot
SetEnvIfNoCase User-Agent "GetRight" bad_bot
Order Allow,Deny
Allow from all
Deny from env=bad_bot
I've tested it on an abandoned domain, the headers look fine.. but past experience tells me to get a second opinion from someone who understands this stuff.
1) Is this in the best order? ie, not likely to cause double or triple redirects?
2) Any loops or other errors?
3) Is there any way to say redirect all index.* to their proper folder? (I have a few folders with index.php, some old ones with .shtml.. messy I know but this site is 8 years old and I prefer to not move URLs if I can avoid it. Made that mistake once already with it.)