And welcome
Well, to protect a folder, you can use .htaccess (AuthUserFile) and .htpasswd, and you can reuse the same .htpasswd for several .htaccess.
The .htaccess should mention the path to the .htpasswd as well a few options such as :
- Code: Select all
AuthUserFile /home/full/absolute/path/to/the/.htpasswd
AuthGroupFile /dev/null
AuthName "the name of the authorisation you want"
AuthType Basic
<Limit GET POST>
require valid-user
</Limit>
You can use the exact same .htaccess in as many folder as you like, they all be linked to the same .htapasswd. The .htpasswd should be composed of a list of users with encrypted passwords, something like :
- Code: Select all
user1:jfGRQGRGsdfgd
user2:piofjzefefzeqFDd
The encryption used usually is md5(), but, depending on the type of install, on shared hosting mostly, it is possible that you'd need to add a key (could be composed of 2 letters) in the password prior to md5() it. This is to be checked from your host.
Then, if protecting several folder is not a problem, it's a bit more tricky if you want to protect the root level and not all of the sub folder. I actually never dealt with such settings.
What occurs is all sub folder of a protected folder should as well be protected.
But, you should be able to override the authorisation if you add a new auth .htaccess in the sub folder needing another auth, and add something like :
- Code: Select all
Satisfy any
Order Deny,Allow
Allow from all
In the sub folder's .htaccess you want to stay public.
++