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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

More .htaccess help needed for novice 1

Status
Not open for further replies.

Newposter

Technical User
May 9, 2002
735
US
OK, I'm setting up a domain on a Win2K Pro machine with Apache 1.3.2 Win32. Basics work fine. I referenced the .htaccess file in my httpd.conf file and created a new .htaccess file as described in other posts, referencing the directory path I want to restrict. Also ported an .htpasswd file from a unix site that I have hosted for me by another company. When I try to enter the restricted directory, I get right in, no password prompt at all. What else do I need to do in a Windows environement? Also, is the encription valid from the unix .htpasswd file? How do I create new usernames and passwords in Windows?
 
content of .htaccess which is in my download directory
C:\Program Files\Apache Group\Apache\htdocs\Downloads

AuthType Basic
AuthName "Restricted Files"
AuthUserFile conf/.htpasswd
require user download

and the password file .htpasswd it's refering to is in
C:\Program Files\Apache Group\Apache\conf

Using that with the bit of config file I gave you earlier works for me. -----------------
[flush]
 
The .htaccess file should be in the directory you want to restrict access to.

In the .htaccess file you need something similar to:

AuthName "Restricted Area"
AuthType Basic
AuthUserFile /home/webmastr/auth/authuser
<Limit GET>
require valid-user
</Limit>

authuser is the name of my authentication file it contains the username and passwords for the valid users.


In the httpd.conf you need this:

<Directory &quot;/home/webmastr/pub/html/private&quot;>
AllowOverride All
</Directory>

This forces the server to reference the .htaccess file in the private directory.

Now to get the username and passwords added to the authuser file (I do not know if it is the same if your using Windows with Apache but it might be).
At the command line type:

htpasswd path to authentication file username


That is all there is to it.

Just a side note: You should edit any files you post in here to make sure your REAL IP and any personally identifiable things like your EMAIL address are fake or commented out. Especially showing the world your config file for your webserver which can be used against you.
 
OK, I erased the AuthGroupFile /dev/null line in the .htacces file entirely, and changed my AuthUserFile path to / and now I DO get the password prompt window!
Now I need to create the contents of the .htpasswd file, and PcLinuxGuru's suggestion of the htpasswd command was not a valid command in a Win32 cmd window.
Can someone tell me how to create the password file in Win2K?
Almost there!
 
Hi mate,

The way I do it on a windows server is just to create it as normal text..

Just make sure that the .htaccess is in a directory outside your server root.. For example. /ht/.htaccess which would be a directory on the root of your hard drive called ht.

This directory cannot be accessed by a browser.

Hope this helps Wullie

 
OK, I found the htpasswd.exe in my /bin/ directory, and used it to create an .htpasswd. However, even with the paths set correctly to it in the .htaccess file, it fails to recognize the password that I created for the username. Will try a &quot;test.htpassword&quot; filename to see if it makes a difference.
 
PcLinuxGuru (TechnicalUser) Thanks! I was having the same problem and adding <Directory &quot;/home/webmastr/pub/html/private&quot;>
AllowOverride All
</Directory>

to the httpd.conf fixed me right up =D
 
Correct, Wullie, thanks. This has been working fine for me for a month now. It was a syntax issue in the AuthuserFile line that prevented .htaccess from finding and using the .htpasswd file. Now if my first customer would just get the payment in so I don't have to cut him off...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top