For some directories, we often need to specify a second-level domain name for them, so how to do it? Next, I will explain it with my own practice.
Due to the first contact with centos, I had to resort to network resources. Then I learned that the mod_rewrite module needs to be enabled. The specific method is as follows:
Open the Apache installation directory /etc/httpd/conf\httpd.conf with a text editor, find the line "#LoadModule rewrite_module modules/mod_rewrite.so", and remove the "#LoadModule rewrite_module modules/mod_rewrite.so" #"; Continue to find "AllowOverride None", modify it to "AllowOverride All", and then restart Apache.
In this way, the mod_rewrite module is opened, and its function is very powerful. Here I only talk about how to bind the second-level domain name.
Similarly, we enter the following statement at the end of the httpd.conf file:
RewriteEngine on
RewriteMap lowercase int:tolower
RewriteMap vhost txt:/etc/httpd/vhost.map
RewriteCond ${lowercase:%{SERVER_NAME}} ^(.+)$
RewriteCond $ {vhost:%1} ^(/.*)$
RewriteRule ^/(.*)$ %1/$1
Then restart Apache
. In this way, we can freely set and bind the second-level domain name.
Reminder: Please back up this httpd.conf, I accidentally deleted it, and it was extremely miserable!!
After that, create a new vhost.map under /etc/httpd (ie, the Apache installation directory), and use a text editor to bind it. It is extremely simple. I wrote it like this:
bbs.nvdchina.com /var/www/html/bbs
home.nvdchina.com /var/www/html/home
potplayer.nvdchina.com /var/www/html/potplayer
We can bind the second-level domain name to the directory at will, save it, and do not need to restart Apache, which is very convenient.
How to bind a second-level domain name to a second-level directory in Centos
Guess you like
Origin http://43.154.161.224:23101/article/api/json?id=326427569&siteId=291194637
Ranking