.htacess allow from local and deny all except one user agent

295 Views Asked by At

I have local page. All I want to access it from my phone and my computer. There is no chance to have static IP.

RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} !MyUserAgent [NC]
RewriteRule ^ - [F,L]

Order Deny,Allow
Deny from all
Allow from MYLocalIp

These codes are not working together. How can I use them together?

1

There are 1 best solutions below

0
anubhava On BEST ANSWER

This all can be done in single rewrite rule itself:

RewriteEngine On

RewriteCond %{HTTP_USER_AGENT} !MyUserAgent [NC,OR]
RewriteCond %{REMOTE_ADDR} !=11.22.33.44
RewriteRule ^ - [F,L]

Where 11.22.33.44 is your local IP address.