Linux about Apache set level two domain name binding two level directory method

Source: Internet
Author: User

Background: For some forum sites, some directories need to set up a two-level domain name to visit, this time will be in Apache with a two-level domain name binding level two directory.

Method:

1. First you need to find the Apache installation path, locate the Apache configuration file httpd.conf in the Conf folder under the APAHCE installation path, open the configuration file, first make sure the DocumentRoot path is commented out (if the path is not commented out, Then no matter with vhost or URL rewrite, will not be able to find the level two domain name bound to the level two directory)

2. Open the Mod_rewrite module and find the "#LoadModule rewrite_module modules/mod_rewrite.so" line in the httpd.conf configuration file, remove the "#" from the front and continue looking for " AllowOverride None ", modified to" allowoverride all ", restart Apache

3. Continue editing the httpd.conf configuration file and add the following code at the end of the configuration file:

Rewriteengine on

Rewritemap lowercase Int:tolower

Rewritemap vhost txt:/etc/#这里是指vhost. Map location Path

Rewritecond ${lowercase:%{server_name}} ^ (. +) $

Rewritecond ${vhost:%1} ^ (/.*) $

Rewriterule ^/(. *) $%1/$1

Add good after save exit, restart Apache

4. Under the VHOST.MAP path specified above, create a new Vhost.map file, the content of the file can be freely filled in the two level domain name and its bound path

The format is as follows:

Www.***.com/usr/local/html/...

Bbs.www.***.com/usr/local/html/...

Here casually binding, do not need to restart the Apache service, add good after saving exit, visit the site to achieve the desired effect.

Linux about Apache set level two domain name binding two level directory method

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.