Difference between revisions of "How to bypass .htpasswd for certain IPs Apache"

From Brian Nelson Ramblings
Jump to: navigation, search
(How to bypass .htpasswd for certain IPs with Apache)
(Wordpress wp-admin directory)
Line 26: Line 26:
  
 
  <Directory "/var/www/wordpressdomain/wp-admin/">
 
  <Directory "/var/www/wordpressdomain/wp-admin/">
AuthUserFile /path/to/your/.htpasswd
+
  AuthUserFile /path/to/your/.htpasswd
AuthName "Please Log In"
+
  AuthName "Please Log In"
AuthType Basic
+
  AuthType Basic
require valid-user
+
  require valid-user
Order allow,deny
+
  Order allow,deny
Allow from xxx.xxx.xxx.xxx
+
  Allow from xxx.xxx.xxx.xxx
satisfy any
+
  Satisfy any
 
  </Directory>
 
  </Directory>
  
 
This will protect your admin files from everyone but your ipaddress.
 
This will protect your admin files from everyone but your ipaddress.

Revision as of 15:26, 29 May 2014

How to bypass .htpasswd for certain IPs with Apache

If you would like to setup Apache authentication on your website to block out unwanted users, example a development site with public access and allow your ipaddress to bypass the authentication.

Setting up your .htaccess or vhost configuration file.

Basic Usage

Add the following, with your variables

AuthUserFile /path/to/your/.htpasswd
AuthName "Please Log In"
AuthType Basic
require valid-user
Order allow,deny
Allow from xxx.xxx.xxx.xxx
satisfy any

You will want to replace the xxx.xxx.xxx.xxx with your ipaddress.

This can be put in your vhost file or .htaccess file.

Wordpress wp-admin directory

Another example would be for wordpress wp-admin folder

<Directory "/var/www/wordpressdomain/wp-admin/">
  AuthUserFile /path/to/your/.htpasswd
  AuthName "Please Log In"
  AuthType Basic
  require valid-user
  Order allow,deny
  Allow from xxx.xxx.xxx.xxx
  Satisfy any
</Directory>

This will protect your admin files from everyone but your ipaddress.