Justin W Hall
Justin W Hall

Reputation: 371

htaccess block referers with keyword

I have a site that is getting hit had with referer spam from sites with a domain that is always:

http://scanner-{somethin-unique-here}.top

How can I use my htaccess file to block all referers from scanner-xxx.top?

Upvotes: 1

Views: 209

Answers (1)

anubhava
anubhava

Reputation: 785286

In your site root .htaccess you can use this rule based on HTTP_REFERER variable to block but just remember those sites can change HTTP_REFERER at some point as well:

RewriteEngine On

RewriteCond %{HTTP_REFERER} https?://scanner-.*\.top [NC] 
RewriteRule ^ - [F]

Make sure this rule is right at the top as first rule.

Upvotes: 1

Related Questions