Answer the question
In order to leave comments, you need to log in
How to disable empty referrers in .htaccess but allow search bots?
So, the task is as follows:
All direct visits to the site should be blocked, i. these are visits with an empty referrer. I do it like this:
RewriteEngine on
RewriteCond %{HTTP_REFERER} ^$
RewriteRule^- [F,L]
Answer the question
In order to leave comments, you need to log in
Search bots specify the From header.
RewriteCond %{HTTP_REFERER} ^$
RewriteCond %{HTTP:FROM} !(googlebot|yandex)
RewriteRule ^ - [F]
But what if the referrer -Policy of the site from which they are redirecting prohibits the transfer of referrers? Then the browser will not transmit this header, and your site will block the visitor. Why such discrimination? And how will it save from an attacker who can easily forge the Referrer header?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question