User authorization and access control you may have encountered this situation when visiting some websites. when you click a connection, your browser will pop up an authentication dialog box, the account and password are requested to be input. If no, you cannot continue browsing.
User authorization and access control
You may have encountered this situation when visiting some websites. when you click a connection, your browser will pop up an authentication dialog box requesting to enter your account and password, if not, you cannot continue browsing. Some people will think that this is done using CGI. Otherwise, this is the role of the WWW server's user authorization and access control mechanism.
Do you still remember that when you set up the Apache service environment ........ <./Directory> This Command provides different protections for different directories. However, this setting takes effect only after the server is restarted. the mobility is poor. the method for specifying the access control file through the AccessFile command is more flexible, to set a user's access control permission on the Apache server, follow these steps:
1. first, set the httpd. conf file as follows:
# AllowOverride FileInfo AuthConfig Limit # Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec Options Includes FollowSymLinks Indexes AllowOverride All // * pay attention to AllowOverride must be set to All, so that the later. htaccess file works
Order allow, deny Allow from all
#
# Order deny, allow # Deny from all #
# Specify the file name AccessFileName. htaccess for the access control permission configuration
2. create an. htaccess file content
To control the access permissions of a directory, you must create a access control file. The ". htaccess" specified before the file name has the following content structure:
AuthUserFile user account password file name AuthGroupFile group account password file name AuthName screen prompt text AuthType verification method
Password verification method
The AuthType object of the user authentication method provides two conditions: Basic and Digest. The method for setting the password test is the same as that in httpd. conf. Example: AuthUserFile/etc/secure. user AuthName security authentication center AuthType Basic
Require valid-user
3. create a user password file
If you create a user password for the first time, the command format is as follows:
Htpasswd-c password file name user name
In the above example, we put the user password file in the/etc/secure. user file, so we should hold it as follows: