Archive for April, 2012

WordPress: Password-Protected pages not working on folders within WordPress’ directory (Error 404)

Symptoms: You add password-protected directories to folders within your WordPress installation, but instead of showing a password-protection prompt, your browser will show a 404 page instead

This appears to be a common issue for users that try to password-protect folders within an installation of WordPress.
This happens because you did not define a 401/403 (depending on the situation) error page in your main .htaccess file.

In order to correct this, you will need to add the 401 error page to your WordPress’ .htaccess file.
Example of a WordPress .htaccess file:

# BEGIN WordPress
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress

In order to correct this issue, simply create a 401 and 403 error page (on this example I’m using errors/401.html) and add it to .htaccess:

ErrorDocument 401 /errors/401.html
ErrorDocument 403 /errors/403.html

# BEGIN WordPress
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress

And that’s it, save .htaccess and your password-protected folders should work now.