Mobile app version of vmapp.org
Login or Join
Voss4911412

: Should I be returning a 301 or 403 to a bad referrer in my .htaccess? Getting several amounts of bad requests from a particular URL such as site.foo and I would like to redirect all these

@Voss4911412

Posted in: #301Redirect #403Forbidden #Htaccess #Spam #Wordpress

Getting several amounts of bad requests from a particular URL such as site.foo and I would like to redirect all these requests to a dedicated page. The .htaccess code I've researched and implementing is:

RewriteCond %{HTTP_REFERER} site.foobar
RewriteRule ^ bar.com/notallowed.html? [R=301,L]


However, researching HTTP Status codes I'm still unsure with the 301:

301 Moved Permanently
This and all future requests should be directed to the given URI.


or the 403:

403 Forbidden
The request was valid, but the server is refusing action. The user might not have the necessary permissions for a resource, or may need an account of some sort.


So which is the proper usage case and am I using the proper rewrite rule? Is there a proper HTTP status code to use to stop bad referrers?

In my research I ran across:


Redirect based on referrer domain
How do you block a referer but for a specific URL using .htaccess?
Can I block a referring site from my web site
How to block a referrer's full URL and not only the domain
How to block referral traffic from multiple referrers and subdomains in .htaccess file?


In case the next person that runs across this is curious.

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Voss4911412

1 Comments

Sorted by latest first Latest Oldest Best

 

@Heady270

I would use the "403 Forbidden" status. You just need to change your rewrite rule

RewriteCond %{HTTP_REFERER} site.foobar
RewriteRule ^ - [F]


Reference: httpd.apache.org/docs/trunk/rewrite/flags.html#flag_f

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme