---------------------------------------------------
SUMMARY OF THIS THREAD
---------------------------------------------------
NOTE THIS IS FOR WINDOWS VERSION
My small contribution.
1. CREATING .htpasswd FILE
2. CREATING THE .htpasswd FILE1. CREATING .htpasswd FILEHow do I make a .htpasswd file on Windows?Windows will not let you rename a file to ".htpasswd ". You will get an error "You must type a filename" if you try. Instead you can open the file you want to rename in a text editor, ie Notepad. Choose "Save as.." and select "All types (*.*)" next to file type. Now type the filename ".htpasswd " and click save.
Hi are the commands for the htpasswd.exe file.
Usage: htpasswd [-cmdps] passwordfile username
htpasswd -b[cmdps] passwordfile username password
-c Create a new file.
-m Force MD5 encryption of the password (default).
-d Force CRYPT encryption of the password.
-p Do not encrypt the password (plaintext).
-s Force SHA encryption of the password.
-b Use the password from the command line rather than prompting for it.
On Windows and TPF systems the '-m' flag is used by default.
On all other systems, the '-p' flag will probably not work.
Examples:
A. Creating a new password file with users and passwordsAdd following code to a text file and rename it to
createPassFile.bat.
Save it in your ../apache/bin folder.
htpasswd -c -m -b C:\xampp\passGPS\.htpasswd admin adminpass
htpasswd -m -b c:\xampp\mysitepass\.htpasswd frank frankpass
htpasswd -m -b c:\xampp\mysitepass\.htpasswd mark markpass
htpasswd -m -b c:\xampp\mysitepass\.htpasswd mary marypass
Run the file and it will
create a new password file with usernames and password
B. Addin new users and passwords to existing password fileAdd following code to a text file and rename it to
createNewusersToPassFile.bat.
Save it in your ../apache/bin folder.
htpasswd -m -b c:\xampp\mysitepass\.htpasswd frank2 frankpass2
htpasswd -m -b c:\xampp\mysitepass\.htpasswd mark2 markpass2
htpasswd -m -b c:\xampp\mysitepass\.htpasswd mary2 marypass2
Run the file and it will create new usernames and passwords to
existing password fileNote:
When removing the -c paramether the command adds new users to existing file instead of creating a new file.
The .htpasswd file is placed outside the web root for security reasons.
In the example I have created a separate folder c:\xampp\mysitepass to save the site password file.
2. CREATING THE .htaccess FILEHow do I make a .htaccess file on Windows?Windows will not let you rename a file to ".htaccess". You will get an error "You must type a filename" if you try. Instead you can open the file you want to rename in a text editor, ie Notepad. Choose "Save as.." and select "All types (*.*)" next to file type. Now type the filename ".htaccess" and click save.
Save the ".htaccess" file in folder you want to protect.
Example c:\xampp\htdocs\<mysite>\ which will protect your entire site.
Add following code lines to ".htaccess" file.AuthType Basic
AuthName "You need user name and password to access this folder."
AuthUserFile "C:\xampp\mysitepass\.htpasswd"
require valid-user
Conversion to linux system
I think the linux password encryptions are not same as for windows?
I could be wrong? If the password file is not working on linux system when moving you site, use
password generators that many sites offer online (easy to find using google). Most of them are for linux system.
You also need to edit the path format from C:\xampp\mysitepass\ TO something like /usr/local/you/mysitepass/ which is to be the FULL path.
I have not tested the linux version of the code yet. So if you have some corrections then I am happy to reedit the text in read or other section summary.
Thanks again Sharley
Regards
marksu