Set DocumentRoot directory as:/test
There are two domain names, www.test.com,blog.test.com
First open the httpd.conf, find the # include conf/extra/httpd-vhosts.conf, remove the previous # number, set the ServerName 192.168.0.1:80
Then open your httpd-vhosts.conf, open, write
namevirtualhost 192.168.0.1:80 #这第一段很重要, you must set the current server IP<virtualhost ServerName 192.168.0.1:80>
ServerAdmin [email protected]
Documentroot/test
ServerName ServerName 192.168.0.1:80
</VirtualHost>#
<virtualhost servername 192.168.0.1:80 ,
ServerAdmin [email protected]
documentroot/test/test1
ServerName www.test.com
</ Virtualhost>
#
<virtualhost servername 192.168.0.1:80 ,
Serveradmin [email protected]
documentroot/test/test2
ServerName blog.test.com
</ Virtualhost> after restarting Apache you can achieve two domain names to access different directories, and a small suggestion, under the/test set up a index.php, usingheader jump to www.test.com, you can implement a test.com force jump to www.test.com such as effects, blog.test.comnot be affected.
CentOS under the Apache multi-domain single IP configuration