Muktadir Miah
Muktadir Miah

Reputation: 59

How to only allow one user agent on .htaccess?

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.

Upvotes: 6

Views: 6025

Answers (1)

Jon Lin
Jon Lin

Reputation: 143886

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.

Upvotes: 11

Related Questions