I have set up a dev site and want to password protect it so only validated visitors can view the site. All well and good. I am getting annoyed, on my local version, entering my username and password. So, without changing the htaccess file between my local copy and the one on the dev site, how do I password protect the site but allow myself access without having to enter my username and password?
Something like this should do the trick..
Require valid-user
Allow from 127.0.0.1
Satisfy Any
From: http://httpd.apache.org/docs/2.0/mod/core.html#satisfy
I've figured out a cool way to seperate Linux from Windows password files (because I develop in windows and then release to a linux production server).
I just wrote a php script with phpinfo(); on our local and prod server and found the apache module 'mod_win32' to seperate the two of them.
<IfModule mod_win32.c>
AuthUserFile C:\xampplite\your\windows\path.passwd
</IfModule>
<IfModule !mod_win32.c>
AuthUserFile "/your/linux/path/.passwd"
</IfModule>
AuthName "Please Login"
RewriteEngine On
AuthType Basic
Require valid-user
Example for Windows:
AuthType Basic
AuthName "Password Protected Area"
AuthUserFile C:/Apache24/htdocs/.htpasswd
Require valid-user
Order allow,deny
Allow from localhost
Allow from 127.0.0.1
Satisfy Any
Presuming that you are fine entering the password on the dev site - put the auth directives in a VirtualHost on the dev site rather than in the .htaccess file - this way your auth is processed at a server level rather than a directory level.
Also, most modern browsers will probably save your password for you :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With