Question

I have a server which I would like only accessible via my IP address AND require authentication (either HTTP or PHP) for any users outside the IP address.

My current .htaccess file looks like this:

order deny,allow
deny from all
allow from 12.345.67.78

Any ideas on how to require some sort of authentication for users outside of home IP?

Was it helpful?

Solution

You can use mod_setenvif in conjunction with mod_auth.

SetEnvIf Remote_Addr ^12\.345\.67\.78$ ALLOWED

AuthType Basic
AuthName "My Protected Area"
AuthUserFile /full/path/to/passwords
Require valid-user
Satisfy    any
Order      deny,allow
Deny from  all
Allow from env=ALLOWED
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top