Search code examples
.htaccesspassword-protection.htpasswd

Excluding single directory under protected Wordpress site from htpasswd protection


Despite a good deal of searching here I haven't been able to find the solution to this problem.

I have an .htaccess file that is protecting a Wordpress site that I am developing. I would like to protect the entire site except for the directory /images/, but I can't work out how to do this. At the moment my .htaccess file, in the root of the site, looks like this:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

# basic password protection
<IfModule mod_authn_file.c>
 AuthUserFile /home/*****/.htpasswd
 AuthName "Username and password required"
 AuthType Basic
 <Limit GET POST>
  Require valid-user
 </Limit>
</IfModule>

Could someone help me to amend this to allow open access to the /images/ directory?

Thanks,

Nick


Solution

  • You can create a new .htaccess-file in the /images/-directory:

    Order Deny,Allow
    Allow from all
    Satisfy any
    

    This should remove the password protection for this folder.