WordPress: Can't Password Protect A Directory

If you have installed WordPress to the public_html directory and enabled permalinks, you will be unable to password protect a subdirectory even with an .htaccess file. This article will help you password protect a directory and reset the permalinks afterwards.

Note: It is always a good policy to back up your site before you make any changes you wish to revert from later.



Edit Your .htaccess File

  1. Using cPanel's File Manager, edit the .htaccess file that is in your WordPress home folder (in this case, it is likely that is your public_html directory).
  2. Remove from your .htaccess file the line of code that has been bolded:
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    # END WordPress
  3. Replace that line of code with this new one:
    RewriteRule ./ /index.php [L]

    It will look like this:
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ./ /index.php [L]
    </IfModule>
    # END WordPress
  4. Save the changes.


Resetting Permalinks


  1. In the WordPress Dashboard, select "Settings", and then "Permalinks". Copy the current structure.
  2. Click "Default".
  3. Select "Save Settings".
  4. Change the setting back to the original structure you copied in step 1.
  5. Click "Save Settings".

 


  • 17 Users Found This Useful
Was this answer helpful?

Related Articles

How to make WordPress show as Secure in Google Chrome

In order to make your WordPress installation show as Secure in Google Chrome, you'll need ensure...

Temporary URLs in WordPress

To use your Temporary URL with a WordPress installation, you will need to edit the Windows Hosts...

WordPress Optimization

Optimizing your scripts can keep your server and website loading quickly for your visitors. These...

Changing the WordPress Directory

You may want to change the location of your WordPress blog after you have installed it. For...

Fixing the Internal Server Error in WordPress

There are a few possible causes of the 500 Internal Server Error. It is not always due to...