Protect your password with Apache htaccess

Source: Internet
Author: User
Tags http authentication

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.