Block URLs

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

It’s more than possible to block incoming traffic on any website using the hypertext access configuration file (.htaccess).

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 security researcher with more than 20 years of experience in cybersecurity, privacy, malware analysis, analytics, and online marketing. He focuses on clear reporting, deep technical investigation, and practical guidance that helps readers stay safe in a fast-moving digital landscape. His work continues to appear in respected publications, including articles written for Private Internet Access. Through Botcrawl and his ongoing cybersecurity coverage, Sean provides trusted insights on data breaches, malware threats, and online safety for individuals and businesses worldwide.

More Reading

Post navigation

Leave a Reply

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