Single ip Address Configuration for multiple domain names in apache in centos, centosapache
Set the documentroot directory to/test.
There are two domain names: www.test.com and blog.test.com.
First open httpd. conf, find # Include conf/extra/httpd-vhosts.conf, remove the # sign, set ServerName 192.168.0.1: 80
Then open your httpd-vhosts.conf, open, write
NameVirtualHost 192.168.0.1: 80 # This first paragraph is very important. You must set the current server ip address <VirtualHost ServerName 192.168.0.1: 80>
ServerAdmin test@test.com
DocumentRoot/test
ServerName 192.168.0.1: 80
</VirtualHost> #
<VirtualHost ServerName 192.168.0.1: 80>
ServerAdmin test@test.com
DocumentRoot/test/test1
ServerName www.test.com
</VirtualHost>
#
<VirtualHost ServerName 192.168.0.1: 80>
ServerAdmin test@test.com
DocumentRoot/test/test2
ServerName blog.test.com
</VirtualHost> restart apache to access different directories with two domain names. We also recommend that you create an index under/test. php: Use the header to jump to www.test.com. You can use test.com to forcibly jump to www.test.com and so on. blog.test.com is not affected.