Posts Tagged ‘htaccess’

WordPress htaccess and password protected directories..

This is a response i sent to a customer.

Hello,

The solution to this problem is multi-layered.

First, edit /home/xxxx/public_html/.htaccess, and make the Rewrite Rules look like such. You’ll see the addition below RewriteBase.

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

Save this.

Then, in /home/xxxx/public_html/secure/.htaccess, add the following line.

ErrorDocument 401 /401.html

Save this as well.

Finally, in /home/xxxx/public_html/, create 401.html. It can be blank for this to work, but it’s recommend you put something in there as good practice..

Something like this:

<html>
<head>
<title>AUTHENTICATION REQUIRED</title>
</head>
<body>
<h1>AUTHENTICATION REQUIRED</h1>
<p>If you have been granted access, please login with your supplied credentials.</p>
</body>
</html>

Also, make sure your directories are set 755, and not 777.

Please let us know if we can further assist.