Protect Passwords with Apache's HTACCESS_PHP Tutorial

WBOY
Release: 2016-07-13 09:50:29
Original
1034 people have browsed it

Protect passwords with Apache's HTACCESS

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>
Copy after login
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>
Copy after login
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>
Copy after login
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.


www.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...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template