Forum Moderators: phranque
RewriteEngine On
# Redirect non-www to www:
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{THE_REQUEST} ^.*/index\.html
RewriteRule ^(.*)index.html$ /$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . / [L,R=301]
SetEnvIfNoCase User-Agent .*rogerbot.* bad_bot
SetEnvIfNoCase User-Agent .*exabot.* bad_bot
SetEnvIfNoCase User-Agent .*mj12bot.* bad_bot
SetEnvIfNoCase User-Agent .*dotbot.* bad_bot
SetEnvIfNoCase User-Agent .*gigabot.* bad_bot
SetEnvIfNoCase User-Agent .*ahrefsbot.* bad_bot
SetEnvIfNoCase User-Agent .*sitebot.* bad_bot
SetEnvIfNoCase User-Agent .*BLEXbot.* bad_bot
SetEnvIfNoCase User-Agent .*Blekkobot.* bad_bot
SetEnvIfNoCase User-Agent .*SEOkicks-Robot.* bad_bot
SetEnvIfNoCase User-Agent .*BotALot.* bad_bot
SetEnvIfNoCase User-Agent .*Alexibot.* bad_bot
SetEnvIfNoCase User-Agent .*BecomeBot.* bad_bot
SetEnvIfNoCase User-Agent .*BunnySlippers.* bad_bot
SetEnvIfNoCase User-Agent .*CheeseBot.* bad_bot
SetEnvIfNoCase User-Agent .*Foobot.* bad_bot
SetEnvIfNoCase User-Agent .*exabot.* bad_bot
SetEnvIfNoCase User-Agent .*grub.* bad_bot
SetEnvIfNoCase User-Agent .*grub-client.* bad_bot
SetEnvIfNoCase User-Agent .*hloader.* bad_bot
SetEnvIfNoCase User-Agent .*httplib.* bad_bot
SetEnvIfNoCase User-Agent .*humanlinks.* bad_bot
SetEnvIfNoCase User-Agent .*InfoNaviRobot.* bad_bot
SetEnvIfNoCase User-Agent .*JennyBot.* bad_bot
SetEnvIfNoCase User-Agent .*Jetbot.* bad_bot
SetEnvIfNoCase User-Agent .*larbin.* bad_bot
SetEnvIfNoCase User-Agent .*LexiBot.* bad_bot
SetEnvIfNoCase User-Agent .*LinkextractorPro.* bad_bot
SetEnvIfNoCase User-Agent .*LinkWalker.* bad_bot
SetEnvIfNoCase User-Agent .*LNSpiderguy.* bad_bot
SetEnvIfNoCase User-Agent .*moget.* bad_bot
SetEnvIfNoCase User-Agent .*MSIECrawler.* bad_bot
SetEnvIfNoCase User-Agent .*naver.* bad_bot
SetEnvIfNoCase User-Agent .*NetAnts.* bad_bot
SetEnvIfNoCase User-Agent .*NetMechanic.* bad_bot
SetEnvIfNoCase User-Agent .*NICErsPRO.* bad_bot
SetEnvIfNoCase User-Agent .*Nutch.* bad_bot
SetEnvIfNoCase User-Agent .*Openbot.* bad_bot
SetEnvIfNoCase User-Agent .*Openfind.* bad_bot
SetEnvIfNoCase User-Agent .*psbot.* bad_bot
SetEnvIfNoCase User-Agent .*ProWebWalker.* bad_bot
SetEnvIfNoCase User-Agent .*RepoMonkey.* bad_bot
SetEnvIfNoCase User-Agent .*scooter.* bad_bot
SetEnvIfNoCase User-Agent .*Stanford.* bad_bot
SetEnvIfNoCase User-Agent .*SpankBot.* bad_bot
SetEnvIfNoCase User-Agent .*SiteSnagger.* bad_bot
SetEnvIfNoCase User-Agent .*suzuran.* bad_bot
SetEnvIfNoCase User-Agent .*Teleport.* bad_bot
SetEnvIfNoCase User-Agent .*WebBandit.* bad_bot
SetEnvIfNoCase User-Agent .*WebCopier.* bad_bot
SetEnvIfNoCase User-Agent .*Xenu.* bad_bot
SetEnvIfNoCase User-Agent .*Zeus.* bad_bot
<Limit GET POST HEAD>
Order Allow,Deny
Allow from all
Deny from env=bad_bot
</Limit> I want to 301 redirect index.html to homepage. Also, I want to 301 redirect all other pages to homepage.
RewriteRule ^([^.]+)index\.html http://www.example.com/$1 [R=301,L,NS] RewriteCond %{THE_REQUEST} index\.html
RewriteRule ^([^.]+)index\.html http://www.example.com/$1 [R=301,L]