Colleagues see http://ip/a This URL address, request to change to access a directory, URL address is http://ip,b directory is soft link in a directory, also require access to a directory is Apache identity authentication, and access to http://ip/ b There is no identity authentication, the following is my solution.
System: CentOS 5.5
Environment: Lamp environment
1. Modify Apache configuration file
code is as follows |
copy code |
vi/etc/httpd/ conf/httpd.conf Namevirtualhost 192.168.1.104:80 <virtualhost 192.168.1.104:80> ServerAdmin rocdk890@gmail.com directoryindex index.html index.php index.htm index.shtml login.php ServerName 192.168.1.104 documentroot/var/www/vhosts/wwwroot/a <directory "/var/www/vhosts/wwwroot/a" options-indexes allowoverride all order Allow,deny allow from all </directory> </virtualhost> |
Take these two points to a directory
The code is as follows |
Copy Code |
documentroot/var/www/vhosts/wwwroot/a <directory "/var/www/vhosts/wwwroot/a" >
|
After saving, restart Apache.
The code is as follows |
Copy Code |
Service httpd Restart
|
2. Go to a directory to add the modified. htaccess file
The code is as follows |
Copy Code |
Vi/var/www/vhosts/wwwroot/a/.htaccess authuserfile/var/www/vhosts/wwwroot/.htpasswd AuthName "Please Enter Your Password" AuthType Basic Require Valid-user
|
3. Go to the B directory to add modified. htaccess file
The code is as follows |
Copy Code |
Vi/var/www/vhosts/wwwroot/b/.htaccess Satisfy any Order Deny,allow Allow from all
|
This allows the B directory to not be restricted by identity authentication.
4. Soft chain B directory to a directory
The code is as follows |
Copy Code |
Ln-s/var/www/vhosts/wwwroot/b//var/www/vhosts/wwwroot/a/b
|
5. Verify
Well, you can see that the access HTTP://IP is Apache identity authentication, Access http://ip/b is not Apache identity authentication