Protect passwords with Apache's HTACCESS
In staging mode, if you want the specified directory on the website to be open to certain people, you can Use a password protection method for the site - use the htpasswd file to achieve this.
The password file is used to store valid username and password information required to access the website/directory. Basically, Apache provides a program to create password files, the htpasswd program. It is in the bin directory after Apache is installed. For example, after the Windows version of Apache is installed, here:
<ol style="margin:0 1px 0 0px;padding-left:40px;" start="1" class="dp-css"><li>D:/Apache/bin/htpasswd.exe</li></ol>
The steps to create the 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 username and encrypted password.
For example, the username is admin and the password is 123456, then the content in the .htpasswd file may be like this:
<ol style="margin:0 1px 0 0px;padding-left:40px;" start="1" class="dp-css"><li>admin:9dKtKHPyz51Vs</li></ol>
Here, the username is followed by the password, and the password is an encrypted password. arts. You can now upload the .htpasswd file to the root directory.
There is a website that generates .htpasswd files online: http://www.htaccesstools.com/htpasswd-generator/
Step 2: Create .htaccess file
Create a new .htaccess file and write the following content:
<ol style="margin:0 1px 0 0px;padding-left:40px;" start="1" class="dp-css"><li>AuthName "Restricted Area"<br /></li><li>AuthType Basic<br /></li><li>AuthUserFile /home/site/.htpasswd<br /></li><li>AuthGroupFile /dev/null<br /></li><li>require valid-user</li></ol>
Next upload the .htaccess file, and then you can test whether it can be accessed.
AuthName: refers to the name of the pre-accessed area.
AuthType: refers to the authentication method required to use HTTP, Basic refers to basic HTTP authentication.
AuthUserFile: .htpasswd file pointing to the root path of the server.
require: means that only legitimate users listed in the file can access the AuthName area.
http://www.bkjia.com/PHPjc/1018186.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1018186.htmlTechArticleUse Apache's HTACCESS to protect passwords. Use Apache's HTACCESS to protect passwords in staging mode. If you want to specify on the website Directory is open to certain persons, it is possible to password protect the site...