Apache excludes specific directory address implementation method

Source: Internet
Author: User

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

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.