CPanel Password Directories

Wordpress IconThis week I wanted to setup a protected directory on one of my personal sites. CPanel has a built-in feature for setting up password protected subdirectories via the .htaccess file, so I figured I would just use this feature to setup my protected directory. Of course, nothing ever works when you want it to and I soon found out that WordPress was preventing this from working correctly. Every time I tried to access my subdirectory I received a 404 error page from WordPress. After a couple of days of messing with the root .htaccess file, I found a solution.

Edit Root .htaccess

Edit the root .htaccess file and look for the WordPress code which is how Permalinks are created. It will look similar to this.

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

You will need to add a new section above your WordPress code similar to this:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/subdirectory/(.*)$
RewriteRule ^.*$ – [L]

Substitute the directory you want to password protect for “subdirectory”, and then see if you are now able to get your CPanel password protected directory to work.

Still Not Working!

If it still does not work, then you have another .htaccess file that has the same WordPress code. For my domain, I install the WordPress files in a subdirectory named “main”, and when I inspected the root .htaccess file and the .htaccess file under main, I found the same code. The solution is to remove the WordPress code from the subdirectory in which you have the WordPress files. It should now work.

For further information on WordPress Permalinks conflicting with CPanel password protected directories see:

Filed under: cPanel

No comment yet, add your voice below!

Add a Comment

Your email address will not be published. Required fields are marked *

Comment *
Name *
Email *