How to only allow one user agent on .htaccess?

2020-06-18 02:08发布

问题:

I have been searching all over google and I really need to know how to only allow one user agent on .htaccess?

All I found is how to do it on a Dedicated or private server.

回答1:

If the user-agent that you want to allow is: Lynx/2.8.8dev.12

Then you want these rules in the htaccess of the directory you want to restrict:

RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} !Lynx/2\.8\.8dev\.12 [NC]
RewriteRule ^ - [F,L]

Every other user agent is forbidden with a 403.