I have a tricky one here for the .htaccess guru!
I have a site i.e. mysite.co.uk but i dont want people to be able to go straight to the homepage of mysite.co.uk instead i redirect them to enter.mysite.co.uk a subdomain of mysite.co.uk.
Currently I have this:
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_REFERER} !^http://mysite.co.uk [NC]
RewriteCond %{HTTP_REFERER} !^http://enter.mysite.co.uk [NC]
RewriteRule ^ http://enter.mysite.co.uk [L,R]
RewriteRule ^(.*)$ proxy.php?url=$1 [L,QSA]
This does what I want it to but the problem is the redirect is turning away Google bot and all other search engines, so my question is this is there any code I can add to allow a number of the larger search engine bots/spiders to enter without having to have come from the refering url i.e. enter.mysite.co.uk
Help greatly appreciated with this im pulling my hair out and nearly bald now :)
Add a negative condition for search bots like this:
RewriteCond %{HTTP_USER_AGENT} !(googlebot|adsbot-google|bingbot|msnbot|psbot|gigabot|twitterbot|linkedinbot|yahoo-mmcrawler|pingdom\.com_bot) [NC]
RewriteCond %{HTTP_REFERER} !^http://mysite.co.uk [NC]
RewriteCond %{HTTP_REFERER} !^http://enter.mysite.co.uk [NC]
RewriteRule ^ http://enter.mysite.co.uk [L,R]
RewriteRule ^(.*)$ proxy.php?url=$1 [L,QSA]
This way your first rule won't be applicable for listed search bots.