WordPress: Can't Password Protect A Directory Print

  • 17

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".

 



Was this answer helpful?

« Back