htaccess password except for this IP

Thingmand
Thingmand used Ask the Experts™
on
I need to protect a test site with a .htaccess password, except for some specific IP addresses, which should be allowed with no password.

How can I do that?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Multitechnician
Top Expert 2014
Commented:
Hello Thingmand,

Replace x.y. by you IP (ex : 10.2. for allowing 10.2.X.Y)


Deny from all
Order deny,allow
 
AuthName "Exception networks"
AuthUserFile /path/to/.htpasswd
AuthType Basic
Require valid-user
Allow from w.x.
Satisfy Any 

Open in new window

Commented:
I haven't tested this and I'm not sure if it'll work but you can try placing the following on your .htaccess file:

<IfModule mod_security.c>
SecFilterEngine On
SecFilterSelective REMOTE_ADDR "123\.123\.123\.1" "nolog,noauditlog,pass"
</IfModule>

Replace "123\.123\.123\.1" with your actual IP, backslash in front of the periods.

You'll need to have a server with mod_security.c installed.

- Jon

Author

Commented:
Perfect - thanks!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial