Home » Blog » Cybersecurity » Cybersecurity » How To Block Incoming Traffic, Backlinks, Attempted Site Hijacks, And Multiple URLs In The .htaccess File
Block URLs

How To Block Incoming Traffic, Backlinks, Attempted Site Hijacks, And Multiple URLs In The .htaccess File

Blocking incoming traffic, attempted site hijacks, and multiple URLs in the hypertext access configuration file

Block URLs in htaccess fileIt’s more than possible to block incoming traffic on any website using the hypertext access configuration file (.htaccess). Sometimes blocking URLs using rewrite conditions in the .htaccess file can stop or slow down attempted website hijackings, where a malicious website has either forwarded a domain or rewritten their domain to leach on another (victims) website’s traffic. You can also use the .htaccess file to block spam links or block low ranked websites which have linked to your website’s content to prevent Google’s sandbox from taking effect on your website (if this is the case, it is sometimes better to contact the websites and kindly ask for them to remove your links).

How to block a single URL in the .htaccess file

Down To block a single URL copy and paste the code below into your .htaccess file.

Change only domain\.com to the domain you wish to block, keep the URL in the exact same format, adding a \ before each extension (ie: botcrawl/.com or botcrawl/.co/.uk).
[Normal_Box]

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

[/Normal_Box]

How to block multiple URLs in the .htaccess file

Blocking multiple URLs in the .htaccess file is a little different than blocking a single URL. [NC,OR] must follow every URL on the conditions list starting with the first one, excluding the last URL on the list.

Down To block multiple URLs copy and paste the code below into your .htaccess file.

Change only domain\.com (or domain2, etc.) to the domain you wish to block, keep the URL in the exact same format, adding a \ before each extension. (ie: botcrawl\.com or botcrawl\.co\.uk). To add more domains simply follow the previous rule as stated above concerning  [NC,OR].
[Normal_Box]

RewriteEngine on
# Options +FollowSymlinks
RewriteCond %{HTTP_REFERER} domain\.com [NC,OR]
RewriteCond %{HTTP_REFERER} domain2\.net [NC,OR]
RewriteCond %{HTTP_REFERER} domain3\.co\.uk
RewriteRule .* - [F]

[/Normal_Box]
 

Sean Doyle

Sean is a tech author and engineer with over 20 years of experience in cybersecurity, privacy, malware, Google Analytics, online marketing, and other topics. He is featured in several publications.

More Reading

Post navigation

2 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

What do SSL certificates actually do?

How To Change Go Daddy Nameservers

Why sending entire posts to your RSS subscribers is a bad idea