Jump to content

Password protecting a subfolder


artaylor
 Share

Recommended Posts

Hi,

I am trying to password protect a subfolder (not used by PW installation) using standard .htaccess and .htpasswd. However, the main .htaccess file in PW is creating a 404 error. If I disable the main .htaccess, it works. My knowledge of .htaccess and rewrite rules is very limited and nothing I have tried has allowed this to work.

All suggestions welcome.

Thanks

Link to comment
Share on other sites

@artaylor, I tested this and PW does not interfere with htpasswd protection of a folder in the site root. Your folder structure should look like this:

/protected-folder/
    protected-file.txt
    .htaccess
    .htpasswd
/site/
/wire/
...etc

This works for protecting 'protected-file.txt' (or any file in this folder). But you cannot get the directory listing for 'protected-folder' unless you explicitly enable indexes in /protected-folder/.htaccess by adding this:

Options +Indexes

 

  • Like 2
Link to comment
Share on other sites

On 19/06/2017 at 6:15 PM, Robin S said:

@artaylor, I tested this and PW does not interfere with htpasswd protection of a folder in the site root. Your folder structure should look like this:


/protected-folder/
    protected-file.txt
    .htaccess
    .htpasswd
/site/
/wire/
...etc

This works for protecting 'protected-file.txt' (or any file in this folder). But you cannot get the directory listing for 'protected-folder' unless you explicitly enable indexes in /protected-folder/.htaccess by adding this:


Options +Indexes

 

@Robin S, Thanks. I do have a separate folder from the root with it's own .htaccess file like you have here. However, it does not work unless I remove the .htaccess file in the root of the site (the PW one). I will try again.

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...