cancel
Showing results for 
Search instead for 
Did you mean: 

Password Protecting Webspace

billinswansea
Member

 

I have a paid-for BT hosted site and am trying to protect part of this using .htaccess / .htpasswd. I have placed the password file with encrypted password at public (root) and the .htaccess file in the folder I wish to protect. I do get prompted for username / password when I attempt to access the protected folder but the details entered are not recognised.

 

The .htaccess file looks like:

 

AuthUserFile /public/myfolder/protected/.htpasswd
AuthType Basic
AuthName "Protected Folder"
Require valid-user

 

Any suggestions as to errors in this process would be appreciated.

 

Bill

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

dave
Guru

ok, the .htpasswd file can be placed anywhere you like, but the AuthUserFile line in the .htacces file needs to point to the location of the .htpasswd file and not the folder you want to protect (although these may be the same).

 

the .htaccess file must go in the directory you wish to protect

 

If you have placed the .htpasswd file into the root then your AuthUserFile line should read:

AuthUserFile /services/webpages/g/o/goweralg.co.uk/.htpasswd

 

If you have placed the .htpasswd file into the actual directory you want to protect then your AuthUserFile line should read:

AuthUserFile /services/webpages/g/o/goweralg.co.uk/public/myfolder/protected/.htpasswd

 

Anywhere else and hopefully you get the idea!

View solution in original post

12 REPLIES 12

houdini
Member

Have you subscribed to the Advanced / Professional web hosting package with BT?

 

.htaccess will only work if you have this package.

dave
Guru

This is not true houdini.

 

It is the path to the .htpasswd file that is not right. You need to specify the fulll server path to your websace which you will probably not be aware of

 

Give me your domain name and I will post the correct path for you.

 

Also, please confirm where you have placed the .htpassed file as you stated you have placed in in root but your .htaccess file seems to suggest otherwise.

Message Edited by dave on 15-05-2009 07:06 PM

billinswansea
Member

 

Many thanks

 

I have just the base hosting package (5 pounds / month) and not the professional (where I could I think protect using the provided management tools).

 

Domain is www.goweralg.co.uk

 

I have (initially) put a trial password file at 'public' level where the index.htm for the site is. Using FTP on login I initially see (secure / public / private / logs and cgi-bin). I wish to protect (say) a 'protected' folder found under 'myfolder' under public as below.

 

 

AuthUserFile /public/myfolder/protected/.htpasswd
AuthType Basic
AuthName "Protected Folder"
Require valid-user 

 

Many Thanks

 

Bill

 

 

 

 

 

dave
Guru

ok, the .htpasswd file can be placed anywhere you like, but the AuthUserFile line in the .htacces file needs to point to the location of the .htpasswd file and not the folder you want to protect (although these may be the same).

 

the .htaccess file must go in the directory you wish to protect

 

If you have placed the .htpasswd file into the root then your AuthUserFile line should read:

AuthUserFile /services/webpages/g/o/goweralg.co.uk/.htpasswd

 

If you have placed the .htpasswd file into the actual directory you want to protect then your AuthUserFile line should read:

AuthUserFile /services/webpages/g/o/goweralg.co.uk/public/myfolder/protected/.htpasswd

 

Anywhere else and hopefully you get the idea!

billinswansea
Member

Many thanks for a quick and very clear explanation - I am sure I can work things out from here - though there is no way I could have worked out the AuthUserFile path!!

 

Thanks again

 

Bill

 

TheOtherOne
Super User

Wow Dave that's a very useful post, thanks!

 

TheOtherOne

"He was standing, gazing northwards into the darkness, thoughtful and silent as a young tree in a windless night"

tasoss
Member

dear dave,

 

i followed your directions about the path but had no success. is there anything that I am missing? I have placed the .htpasswd at the root directory and i am using

 

AuthUserFile /services/webpages/g/o/omltd.com/.htpasswd

on my .htaccess, but I cannot go through the login. the domain is omltd.com 

 

is that right? do I need to enable anything with BT?

 

thanks in advance for your help.

dave
Guru

Hello Tassoss,

 

The AuthUserFile path should read as follows:

 

AuthUserFile /services/webpages/o/m/omltd.com/.htpasswd

 

The webspaces are organised in directories on the server based on the first 2 letters of the domain, which is why yours should be /o/m/omltd.com/ rather than /g/o/omltd.com/

 

Hope this helps

freddiewit
Member

Hello guys!

Thanks for all the contributions you have done; it helped me in getting closer to the solution. However, after finalising my .htaccess and .htpasswd I am getting some error message.

 

My .htpasswd is in the root folder and my .htacess code looks like this:

 

AuthUserFile /services/webpages/c/a/carmelcrest.co.uk/.htpasswd
AuthType Basic
AuthName "Staff Zone"
Require valid-user