The previous article describes how to use Apache to implement a method that disables directory access (the list of directories or files listed), prohibits or allows IP and domain names to access directories. In fact, using the. htaccess and Apache
Add the following two lines to the access directory where you want to restrict the user
The code is as follows
Copy Code
Auth_basic "Enter username and password";Auth_basic_user_file nginx_passwd;
HTPASSWD
Online increase or decrease of users in. htpasswd. Online increase or decrease of users in. htpasswd? Phpinclude (. class. Htpasswd. php3); * modify the path of this. htpasswd file * $ htpasswdfileusr2amitc. htpasswd. do not change the value of
The final effect is similar (different browsers have different interfaces ):
If the authentication fails, an HTTP error 401 Authorization Required will be reported.
To implement this function, you need to change the server configuration and set the
The final effect is similar (different browser interfaces vary):
If authentication fails, an HTTP error is reported: 401 Authorization Required.
To do this, you need to change the server configuration and set the username and password for the
Sometimes you need to obtain the content of the. htpasswd file, you can use the following code class. if you need it, you can refer to the. htpasswd File example:
User1: {SHA} kGPaD671VNU0OU5lqLiN/h6Q6ac =
User2: {SHA} npMqPEX3kPQTo + x/+ ZckHDrIcQI
Sometimes you need to obtain the content of the. htpasswd file, you can use the following code class. if you need it, you can refer to the. htpasswd File example:
User1: {SHA} kGPaD671VNU0OU5lqLiN/h6Q6ac =
User2: {SHA} npMqPEX3kPQTo + x/+ ZckHDrIcQI
Some directories on the server may not be visible to everyone. The solution is to provide the user name and password for the users who need to access the server. If the authentication fails, an HTTP error 401 Authorization Required will be
How to add and subtract online in PHP. Users in HTPASSWD
Include ("./class. Htpasswd.php3 ");
/* Please modify this. htpasswd file path
*/
$htpasswdfile = "/USR2/AMITC/.HTPASSWD";
Do not modify this line
Echo '
if (!isset ($operation))
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.