SiteCozy

  • My account

How to block bad referring domains in Htaccess?

2018-10-01

Some people found that log files could be a great place to advertise for a website. Consequently, they ping websites with a referer field equal to the domain to advertise. Domains look like  greatauctionmywork.com, mygreatinsurance.com. Some for sure sell services to webmasters because they know that webmasters read the logs. However, it is just another form of SPAM.

In the log file, we can see the name of those domains. Here is the procedure to block those HTTP requests from those advertisers. In Htaccess, add the following directives to block HTTP requests to your website from referring domains

First of all, check your referring domains in your log, and write down the referring domain:

Then, go to htaccess, and add the following code at the top of the file.

RewriteEngine on
RewriteCond %{HTTP_REFERER} autoseoservice\.org [NC,OR] 
RewriteCond %{HTTP_REFERER} anotherseoservice\.org [NC,OR]
RewriteCond %{HTTP_REFERER} bloup\.com
RewriteRule .* - [L,R=404]

Add a [NC,OR] to the command before the last one, if you want to ban an additional domain.

This code will return a 404 error page when they HTTP request contains a referer field equal to the domain specified in the code. You can check it on macOS and Linux using the following:

$ curl --referer http://bloup.com https://sitecozy.com
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL / was not found on this server.</p>
<p>Additionally, a 404 Not Found
error was encountered while trying to use an ErrorDocument to handle the request.</p>
</body></html>

Related Posts:

  • The cheapest generic top level domains below $12/year
  • What about the .tk domain bad reputation ?
  • How to install an additional domain in Cpanel?
Download our Broken link checker freeware here Buy a license key for the Sitecozy broken link checker

Customer Login

Lost password?

Categories

  • Webmaster advice
  • SEO advice
  • Web hosting
  • SiteCozy link checker KB
  • WordPress theme & plugin reviews
  • All articles
Disclosure: We are a professional review site that receives compensation from the companies whose products we review. We test each product thoroughly and give high marks to only the very best. We are independently owned and the opinions expressed here are our own.

Copyright Sitecozy 2018