本文介绍将多个域名绑定到不同的目录的方法,希望对大家有所帮助。 例如:VPS IP:99.110.110.123,需要将abc.com绑定到/var/www/html/dir1,将abc.net绑定到/var/www/html/dir2。
打开http.conf:
在其后添加:
复制代码代码如下:
*IP访问/var/www/html/dir目录
<VirtualHost 99.110.110.123:80> ServerAdmin webmaster@dummy-host.example.com DocumentRoot /var/www/html/dir ServerName 99.110.110.123 ErrorLog logs/dummy-host.example.com-error_log CustomLog logs/dummy-host.example.com-access_log common </VirtualHost> *abc.com与www.abc.com访问/var/www/html/dir1目录 <VirtualHost 99.110.110.123:80> ServerAdmin webmaster@dummy-host.example.com DocumentRoot /var/www/html/dir1 ServerName abc.com ServerAlias www.abc.com ErrorLog logs/dummy-host.example.com-error_log CustomLog logs/dummy-host.example.com-access_log common </VirtualHost> *abc.net与www.abc.net访问/var/www/html/dir2目录 <VirtualHost 99.110.110.123:8081> ServerAdmin webmaster@dummy-host.example.com DocumentRoot /var/www/html/dir2 ServerName abc.net ServerAlias www.abc.net ErrorLog logs/dummy-host.example.com-error_log CustomLog logs/dummy-host.example.com-access_log common </VirtualHost>
附:如果想开其他端口,请按照如下操作(以8080端口为例):
复制代码代码如下:
<VirtualHost 99.110.110.123:8080>
(责任编辑:IT)ServerAdmin webmaster@dummy-host.example.com DocumentRoot /var/www/html/dir3 ServerName abc.com ServerAlias www.abc.com ErrorLog logs/dummy-host.example.com-error_log CustomLog logs/dummy-host.example.com-access_log common </VirtualHost> 实现www.abc.com:8080绑定到/var/www/html/dir3目录。 |