I would like to use .htaccess to deny access to the site from other hosts. I found the following example on the Internet:

 RewriteEngine on RewriteCond %{HTTP_REFERER} !^http://(www.)?my-site\.ru(/)? RewriteCond %{HTTP_REFERER} !^http://(.*)\.my-site\.ru(/)? RewriteRule ^.*$ - [F] 

Question. A third-party host can disable the HTTP_REFERER header. How to deny access to it?

  • It turns out that you want to completely block access to the site. With such requirements referer will never link to your site. I am wrong? - splash58

1 answer 1

If the client does not transmit the REFERER header, it will be impossible to distinguish the direct access to the site (by hammering the URL in the address bar of the browser) on the server from the link from the other host. So the answer to your question is no way.