htaccess password except for this IP

Thingmand used Ask the Experts™
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?
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2014
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

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"

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


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