How to block visitors by referrer domain using htaccess?

Being a website owner, you might have seen a lot of traffic coming from external websites to your website. Some of these traffic aren't profitable or useful for you anymore, they just cause more server usage & cause website slowness/lagging issues. The below code blocks any & all visitors coming from a domain name that you have added; you should place the code inside .htaccess file where your domain name is pointed to.
#BLOCKING BELOW DOMAIN NAME FROM SENDING TRAFFIC TO OUR DOMAIN NAME 
RewriteEngine on 
RewriteCond %{HTTP_REFERER} externaldomain\.com [NC,OR] 
RewriteCond %{HTTP_REFERER} www\.externaldomain\.com 
RewriteRule .* - [F]
[NC] tells server not to take domain name as case-sensitive. OR lets you add another domain name within same code, we have added www instead.
  • htaccess, mod_rewrite, apache
  • 1 Users Found This Useful
Was this answer helpful?

Related Articles

How to block bad bots using htaccess?

There are hundreds of search engines, thousands of crawlers & bots do crawl your website which is...

How to change server default signature using htaccess?

There are chances where a bot or a user tries to access a non-existing page which shows default...

how to change your web servers date timezone using htaccess?

You may have hosted your website on a shared server where the DC located in a foreign country &...

How to prevent content & bandwidth theft using htaccess?

When you have a decent website with your own articles, images, media contents, clip arts etc....

How to hide real directory name using htaccess?

Developers use to hide directory name from public so that bots or hacker won't find their website...

Powered by WHMCompleteSolution