Forum Topic: block/redirect traffic coming from a particular website

Forum: .htaccess Forum : Redirecting • Posted by judokai • Updated:

Hi Jeff,

Is it possible to block/redirect traffic that comes from a particular website? I use the following code but it doesn't work.

RewriteEngine on
# Options +FollowSymlinks
RewriteCond %{HTTP_REFERER} samplesite\.com [NC]
RewriteRule .* - [F]

Thank you in advance.

2 Replies to “block/redirect traffic coming from a particular …”

Jeff Starr
Posted by Jeff Starr

It looks like that should work, but there are several things that you can check:

  1. Is the target domain correctly matched in the RewriteCond
  2. Is the referring site sending matching referrer infos
  3. Is mod_rewrite enabled and working on your server
  4. Does WP or another CMS include its own rewrite rules

Then even if all of these things are good, there may be other factors (plugins, scripts, etc) that are interfering in the process.

I hope this provides some clues, good luck.

Posted by judokai •

Thanks so much for your reply, much appreciated.

I'll look into the factors you mentioned above. Currently it doesn't work but I'm sure there's a workaround to it.