| |
| |
|
|
|
|
| |
|
| |
|
| :: |
| Author |
Message |
winsonlee
Joined: 09 May 2007 Posts: 1
|
Posted: Wed May 09, 2007 1:30 pm Post subject: protecting directories using htaccess |
|
|
Under a root directory, I have 7 sub directories.
how can I create a htaccess to protect my root directory and another 3 subdirectories ?
another 4 more i would want it to remain as public. |
|
|
| Back to top |
|
 |
|
 |
dcz Administrateur - Site Admin

Joined: 28 Apr 2006 Posts: 14814
|
Posted: Thu May 10, 2007 9:07 am Post subject: Re: protecting directories using htaccess |
|
|
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: | 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: | 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: | Satisfy any
Order Deny,Allow
Allow from all |
In the sub folder's .htaccess you want to stay public.
++ |
_________________ Useful links :
SEO Forum || SEO Directory || SEO phpBB || SEO phpBB3 || Search
____________________
Liens Utiles :
Forum référencement || Annuaire référencement || Référencement phpBB || Référencement phpBB3 || Recherche |
|
| Back to top |
|
 |
|
| Navigation |
Similar Topics |
|
|
|
|
|
|
|
| |
|
|
|
|
| |
|
|
|
|
| |