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} http://site.foobar
RewriteRule ^ https://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.