Here is my existing .htaccess code for reference:
RewriteEngine on
RewriteCond %{HTTP_REFERER} offendingdomain
RewriteRule ^ http://www.google.com/? [R=301,L]
Everything I have read so far on SO and other sites says this should work, but the offending site is still not being redirected from my own. In addition, I've tried blocking with the code below but that too is failing to work.
RewriteEngine on
Options +FollowSymlinks
RewriteCond %{HTTP_REFERER} offendingdomain [NC]
RewriteRule .* - [F]
Does anyone have any ideas as to why this doesn't work and how I should go about fixing it? Thanks in advance...any help would be greatly appreciated!
Thanks - Brandon
When you try to do anything on the offending site (click on a link, or use the search form), the redirect is working perfectly. So it seems to me like as long as the traffic is being referred
, the %{HTTP_REFERER}
condition is doing its job.
Let's try to add another conditions in case someone tries to access the bad site directly (in which case there is no referral). Therefore, we'll beef up the existing rule:
RewriteEngine on
RewriteCond %{HTTP_REFERER} offendingdomain [OR]
RewriteCond %{HTTP_HOST} offendingdomain
RewriteRule ^ http://www.google.com/? [R=301,L]