I need some help with htaccess. I tried to code a htaccess that will that will allow search engine visitors and bots, and redirect everyone else. My problem is when the visitor is a bot or not from the search engines, the site seems be caught in a loop
Basically what I want htaccess to do:
-htaccess sees the referrer is from a search engine and the visitor will be redirected to a linkA.
-If visitor is not from a search engine, the htaccess checks if the visitor is a bot, if so the bot will be able to crawl the site.
- if visitor do not have a search engine referrer and is not a bot, the visitor will be redirected to linkB.
Here is what I wrote in My htaccess
Basically what I want htaccess to do:
-htaccess sees the referrer is from a search engine and the visitor will be redirected to a linkA.
-If visitor is not from a search engine, the htaccess checks if the visitor is a bot, if so the bot will be able to crawl the site.
- if visitor do not have a search engine referrer and is not a bot, the visitor will be redirected to linkB.
Here is what I wrote in My htaccess
Code:
RewriteBase /
#
#First redirect any visitors from search engines to url
RewriteEngine on
RewriteCond %{HTTP_REFERER} ^.*yahoo.*$ [OR]
RewriteCond %{HTTP_REFERER} ^.*google.*$ [OR]
RewriteCond %{HTTP_REFERER} ^.*msn.*$ [OR]
RewriteCond %{HTTP_REFERER} ^.*live.*$ [OR]
RewriteCond %{HTTP_REFERER} ^.*ask.*$ [OR]
RewriteCond %{HTTP_REFERER} ^.*aol.*$
RewriteRule ^.*$ http://www.linkA.com [R,L]
#
#Now allow specific bots, and redirect everyone else
RewriteCond %{HTTP_USER_AGENT} !^googlebot [OR]
RewriteCond %{HTTP_USER_AGENT} !^slurp [OR]
RewriteCond %{HTTP_USER_AGENT} !^Yahoo-MMCrawler [OR]
RewriteCond %{HTTP_USER_AGENT} !^msnbot [OR]
RewriteCond %{HTTP_USER_AGENT} !^SandCrawler [OR]
RewriteCond %{HTTP_USER_AGENT} !^Teoma [OR]
RewriteCond %{HTTP_USER_AGENT} !^Jeeves
RewriteRule ^.*$ http://www.linkB.com [R,L]
Last edited: