Apache Web Server: Procedures for Setting up Password for your web site


1.       Run the file htpasswd.exe from the command prompt (the file is located in the BIN directory within the apache directory):

htpasswd.exe -c password.txt_name ahmad

password_file_name being the name of the password file, and the username being the username of your choice. After entering the username, you get a password prompt. Enter your pass, and then confirm it. The new password file is located in the bin folder, you can move it to where-ever you would like.


2        Create the .htaccess file. Place it into the directory in which you want to password protect. Inside the .htaccess file, this is what you should paste:


AuthType Basic
AuthName "Password Required"
AuthUserFile /www/passwords/password.txt
Require valid-user


 

After you have put it into the folder where you want a password, you have to edit the httpd.conf file.


3        <IfModule mod_alias.c>

Find the line "<IfModule mod_alias.c>", and anywhere beyond that, you will need to add the directory preferences for your .htaccess file, or something of the sort.


<Directory "C:/Apache/Apache/htdocs/passwordprotectedfolder/">
Options Indexes FollowSymLinks MultiViews Includes
AllowOverride AuthConfig
Order allow,deny
Allow from all
</Directory>



4.       Save the file, restart apache, and attempt to go to that location on your site- it should display a password prompt, and it should work with your pass.



No comments:

Post a Comment