Protect your password with Apache htaccess
CHSZS, reprint need to indicate. Blog home: Http://blog.csdn.net/chszs
In staging mode, if you want the specified directory on your site to be open to someone, you can use a password-protected method for your site-using the htpasswd file.
The password file is used to store valid user name and password information that requires access to the site/directory. Basically, Apache provides a program to create a password file, the HTPASSWD program. In the bin directory after Apache installation, such as the Windows version of Apache after installation, here:
D:/Apache/bin/htpasswd.exe
The steps to create a htpasswd file are detailed below.
Step 1: Create the. htpasswd file
First, you need to create a file named. htpasswd, which is used to store the user name and the encrypted password.
For example, the user name is admin, the password is 123456, then the content in the. htpasswd file may be this:
admin:9dKtKHPyz51Vs
Here, the user name is followed by the password, and the password is encrypted ciphertext. You can now upload the. htpasswd file to the root directory.
There is a Web site that generates. htpasswd Files Online: http://www.htaccesstools.com/htpasswd-generator/
Step 2: Create the. htaccess file
Create a new. htaccess file and write the following:
AuthName "Restricted Area"AuthType BasicAuthUserFile /home/site/.htpasswdAuthGroupFile /dev/nullrequire valid-user
Next upload the. htaccess file, and then you can test to see if you can access it.
AuthName: Refers to the name of the pre-visited zone.
AuthType: Refers to the authentication method that is required to use HTTP, and basic refers to fundamental HTTP authentication.
AuthUserFile:. htpasswd file that points to the root path of the server.
Require: Refers to only legitimate users who have a list in the file to access the AuthName area.
Protect your password with Apache htaccess