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