Because I need to password protect a subdirectory using cPanel, I modified Wordpress's .htaccess rule as instructed here: https://wordpress.org/support/topic/password-protect-a-directory-with-htaccess

This is my current wordpress rewrite block:

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

# END WordPress

Notice particularly this line:

RewriteRule ./ /index.php [L]

The normal wordpress Rewrite Rule is this:

RewriteRule . /index.php [L]

It works perfectly for the password-protected directory. But I seem to have lost the rewrite for when a page gets loaded without the trailing slash.

Before I changed this, Wordpress would look at a url like this: http://example.com/about-us and load it up as http://example.com/about-us/ (with a trailing slash).

Now it simply goes to a Not Found page. It's not even loading the theme's 404 page.

Any ideas how to fix this without mucking up my password-protected directory?

1 Answer 1


You can use question mark:

RewriteRule ./?$ /index.php [L]
  • That does fix the trailing slash Not Found error. But now the password-protected directory is not working again. :(
    – maguijo
    Jun 20, 2016 at 13:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.