Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

htaccess on WIn XP Pro

Status
Not open for further replies.

gussy1

Technical User
Dec 22, 2002
63
IE
I have just set up APache HTTP server on XP Pro. How do I protect a diectory say htdocs/home/private using a htaccess and htpasswd file. I know how to do it on a unix server but I can't seem to get the htpasswd path right or something because the pages in the private folder just give an error!

Could someone give me a step-by-step show of the setup.

Much appreciated
 
Syntax is slightly different for Windows. Your .htaccess file should be placed in the directory to be protected, and should look like this:

AuthUserFile "C:/Apache/htdocs/domain/protected/.htpasswd"
AuthGroupFile /null
AuthName "Restricted Area"
AuthType Basic

<Limit GET POST>
require valid-user
</Limit>

Then go to the Command Prompt and browse to the PERL directory that contains the htpasswd.exe file, and create the .htpasswd file. By default this file will end up in that PERL directory, so after creating it, move it to the path specified in the .htaccess file. You can and should encrypt the .htpasswd file. Note that a unix file is encrypted differently, so you can't re-use the password file from one system to the other. Newposter
&quot;Good judgment comes from experience. Experience comes from bad judgment.&quot;
 
Great thanks. I didn't know that Windows and Unix enctypted the htpasswd file differently - that would have had me in a right pickle! I found the htpasswd.exe file in the Apache/bin dir and not PERL. I guess it doesn't really matter once I find it!

Thanks
 
Sorry, you're right, it is part of Apache and not PERL. What I found is that I couldn't take a unix .htpasswd file and use it on the Windows server that I moved the domain to. Only thing I can think of is that it's encoded differently, and I did read that MD5 for Windows is different. So I had to recreate it.

I also found that I had to browse to the apache/bin directory in order to execute the .htpasswd.exe, rather than type the whole command path at the prompt. But then I tried to type the destination in the commmand (.htpasswd.exe c:/apache/htdocs/domain/protected/.htpasswd -c user) and it wouldnt' accept that. So I created the .htpasswd in the apache/bin folder, then moved it to the correct one. Newposter
&quot;Good judgment comes from experience. Experience comes from bad judgment.&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top