Apache uses. htaccess file to achieve user authentication

xiaoxiao2021-03-06  45

In this example, the virtual directory of / OPT is set, and the .htaccess file implements user authentication for / opt virtual directory 1. Modify /etc/httpd/conf/httpd.confdocumentroot "/ backup" alias / html / "/ var / www / html "Alias ​​/ opt" / opt "# define / opt virtual directory ## Each directory to which Apache has access can be configured with respect # to which services and features are allowed and / or disabled in that # directory (and its subdirectories). ## First, we configure the "default" to be a very restrictive set of # features. # Options Indexes FollowSymLinks AllowOverride None Order allow, deny Allow from all Options Indexes FollowSymlinks allowoverride authconfig #

The Allowoverride Authconfig is a row represents user authentication for files in / opt directory. ORDER ALOW, DENY # first allows the allow from all # to allow all computers to access the folder 2.

Create a file under the directory / OPT restricted access. Htaccess, its contents are as follows: [Root @ Test7 OPT] # more .htaccess authname "test" authtype baricauthuserfile /etc/httpd/test.txtRequire Valid-user

Any user can access 3 in the file specified by AuthuserFile.

The program htpasswd included with Apache generates text files containing usernames and passwords: /etc/httpd/test.txt, the system automatically generates the content format of each line of content is "User Name: Password". [root @ TEST7 httpd] # htpasswd -c test.txt test new password: re-type new password: adding password for user test [root @ Test7 httpd] # more /etc/httpd/test.txt test: wpj8hcoha21fo4. Direct Browser Access HTTP: // IP Address / OPT can be referred to URL: http://www.phpe.net/articles/236.shtml https://support.iap.ac.cn/neet/apachemanual/zh-cn /Programs/htpasswd.html

转载请注明原文地址:https://www.9cbs.com/read-71555.html

New Post(0)