Home » Blog » Web Design » 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]
 

Lead Editor

Jared Harrison is an accomplished tech author and entrepreneur, bringing forth over 20 years of extensive expertise in cybersecurity, privacy, malware, Google Analytics, online marketing, and various other tech domains. He has made significant contributions to the industry and has been featured in multiple esteemed publications. Jared is widely recognized for his keen intellect and innovative insights, earning him a reputation as a respected figure in the tech community.

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.

How to build a professional WordPress website from scratch

Honest and Realistic SEO Advice For Bloggers – Page Rank vs. People Rank

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