Virtual Host configuration file httpd-vhosts.conf, need to join
<Directory/mysqldata/www>
AllowOverride authconfig
</Directory>
Then in the home directory of the virtual host, which is the DocumentRoot directory
Vi/mysqldata/www/.htaccess
Join
AuthName "Frank Share Web"
AuthType Basic
authuserfile/mysqldata/www/.htpasswd
Require Valid-user
After saving, and then
To create an authenticated user for Apache
Htpasswd-c-M/MYSQLDATA/WWW/.HTPASSWD Test
#第一次创建用户要用到-C parameter is added to the user for the 2nd time without the-c parameter,-m option, encryption
If you want to change your password, you can:
Htpasswd-m. htpasswd test2
Restart Apache, then.
To this, you are already configured to complete. Here's another way to do this:
##################################
VI http.conf
In the corresponding virtual host configuration file segment, add
<Directory/mysqldata/www>
AllowOverride authconfig
AuthName "Zdy"
AuthType Basic
authuserfile/mysqldata/www/.htpasswd
Require Valid-user
</Directory>
After saving, and then
To create an authenticated user for Apache
Htpasswd-c-M/DATA/.HTPASSWD Test
Control the use of FilesMatch for a page, as follows
Web site only 1.html page access requires a password, other pages can be directly accessed ...
<Directory/mysqldata/www>
Require all granted
<filesmatch 1.html>
AllowOverride authconfig
AuthName "123"
AuthType Basic
authuserfile/mysqldata/www/.htpasswd
Require Valid-user
</filesmatch>
</Directory>
Report:
Alowoverride None
#允许覆盖参数功能
Some of the parameters of the #表示是否允许额外配置文件. htaccess are overwritten. We can set all the permissions within the httpd.conf.
#不过这样一来, if the user's own personal web page wants to modify permissions, it will cause problems for administrators. As a result, Apache defaults
#可以让用户以目录下的. htaccess file covers some of the function parameters within <Direcoty>. The project is in the provision
#.htaccess What types of permissions can be overridden. The following are common:
#ALL: All permissions can be overridden
#AuthConfig: Only Web authentication (account number and password) can be overwritten
#Indexes: Allow only Indexes aspects of coverage
#Limits: Allows the user to manage Browsable permissions with Allow, Deny, and order
#None: Cannot overwrite, that is, to invalidate the. htaccess file
#使用. htaccess can seriously affect Apache performance and, if not special needs, it is recommended to close
AllowOverride: The type of instruction that is allowed in the. htaccess file (. htaccess file name can be changed and its file name is determined by the ACCESSFILENAME Directive):
None: When AllowOverride is set to none. Do not search for. htaccess files under this directory (you can reduce server overhead).
All: You can use all the instructions in the. htaccess file.
Apache Sets user authentication notes on the virtual host