Spiga

Password Protection Using .htaccess File

Password Protection Using .htaccess File:.htpasswd

We can use the .htaccess file as a password protection.To do this we need to add few lines in the .htaccess file.Add the following below lines in the file.


1)Replace "Section Name" with the name of the part of the site you are protecting.
2)Change
/full/parth/to/.htpasswd to the full server path to the .htpasswd file.

Now write the file .htpasswd.To do this make a text file and write and save it as .htpasswd.Store this file
anywhere within the website (as the passwords are encrypted) but it is advisable to store it outside the web root so that it is impossible to access it from the web.

Once you have created your .htpasswd file (you can do this in a standard text editor) you must enter the usernames and passwords to access the site. They should be entered as follows:

username:password


The
password must be in encrypted form.For this do this:

1)To create the .htpasswd file, use the htpasswd command with the following format:
htpasswd [-c] .htpasswd {username}

After executing this command password,you will be asked to enter the password and it will store the password in the file.
Thats all the file is ready and you are ready to implement the file.

0 comments: