First, you have a top-level domain name that has a universal domain name resolution, such as: domain.com
Second, open the mod_rewrite in the httpd.conf.
After that, at the end of httpd.conf, add the following:
The following are the referenced contents: Rewriteengine on Rewritemap lowercase Int:tolower Rewritemap Vhost Txt:/usr/local/etc/apache/vhost.map Rewritecond ${lowercase:%{server_name}} ^ (. +) $ Rewritecond ${vhost:%1} ^ (/.*) $ Rewriterule ^/(. *) $%1/$1 |
The/usr/local/etc/apache is the path to your Apache server configuration file, which is changed according to the actual situation.
Then, create a file in the directory that contains the path: Vhost.map
Content is:
The following are the referenced contents: Www.domain.com/usr/local/www/data-dist/domain Bbs.domain.com/usr/local/www/data-dist/bbs Anyname.domain.com/usr/local/www/data-dist/anyname |
The above parts are: "Domain name + space + absolute path" form.
Finally, under your site root directory/usr/local/www/data-dist, create the corresponding directory:
Domain, BBS, anyname and so on, theoretically can be unlimited.
In this way, through the browser, access to www.domain.com, the actual access is the/usr/local/www/data-dist/domain directory of files. Similarly, the access bbs.domain.com actually accesses the files in the/usr/local/www/data-dist/bbs directory. Also, you can change vhost.map at any time to add, remove, and modify your level two domain name and the actual path you point to, without restarting Apache.