Extra Password protection for wordpress

In cPanel, there is an option to lock the folders with a password. In normal case, it wont work with WordPress. In my case, below steps worked fine.

1. Add password authentication for the folder with wordpress files from cPanel
2. Create the user and password

3. Add following lines to the .htaccess file in the wordpress root directory

ErrorDocument 401 ./error.html
ErrorDocument 403 ./error.html

 

4. Final .htaccess will look as below:

#next two lines allow password protected directories with 404 errors
ErrorDocument 401 ./error.html
ErrorDocument 403 ./error.html
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /dev/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /dev/index.php [L]
</IfModule>

# END WordPress
#-- Following lines are added for password authentication in the site
AuthUserFile "/home/user_name/.htpasswds/public_html/sub_domain/passwd"
AuthName "dev"
AuthType Basic
require valid-user

 

 

Enjoy 🙂

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s