• I am trying to use htaccess to password protect a subfolder of my WordPress site.

    Ideally, I would like to be https://www.website.com/protected-folder/, but I am getting a 404.

    I have moved my folder to the wordpress directory, making it https://www.website.com/wordpress/protected-folder, but I am still getting a 404.

    The htaccess file in my protected folder has this:

    AuthType Basic
    AuthName “Board Memebers”
    AuthUserFile /.htpasswd
    require valid-user

    The htaccess in my wordpress directory is

    # 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]
    </IfModule>

    # END WordPress

    But I am still getting a 404 error.

    Please help.

Viewing 3 replies - 1 through 3 (of 3 total)
  • I think first you have to force apache to serve the folder request without passing it to WordPress. Do this via the .htaccess in the root of your WordPress installation. This part might be accomplished via the Redirection plugin

    Then the folder will not 404 and its .htaccess becomes of effect.

    Thread Starter erickruk

    (@erickruk)

    Hi St. Even,
    I added this to the top of my htaccess in the main wordpress root.
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_URI} ^/board-members/(.*)$ [OR]
    RewriteRule ^.*$ – [L]
    </IfModule>

    I can now access my file outside of the root, but when I add another htaccess file to that directory, I get a 404 again.

    Thread Starter erickruk

    (@erickruk)

    I think I narrowed down the issue.
    In my wordpress directory, I have the htaccess with that new line of code, which allows me to get to the directory that I want to protect that is outside of the wordpress directory. However, the Root directory of the website has another htaccess file that is basically a duplicate of the wordpress file. But when I try to modify that one as well, my site crashes.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘htaccess password protect a subfolder’ is closed to new replies.