如何在Apache中实现这一目标?

时间:2009-06-30 22:10:31

标签: apache configuration

我指的是指向同一IP的域名。

我想做的是:

当domain_name1访问时,make document_root:/ usr / local / apache / htdocs1

当domain_name2访问时,make document_root:/ usr / local / apache / htdocs2

如何做这份工作?

2 个答案:

答案 0 :(得分:1)

(注意:这个问题应该继续ServerFault

您想要达到的目标是name-based virtual hosting

来自引用页面的示例:

NameVirtualHost *:80

<VirtualHost *:80>
ServerName www.domain.tld
ServerAlias domain.tld *.domain.tld
DocumentRoot /www/domain
</VirtualHost>

<VirtualHost *:80>
ServerName www.otherdomain.tld
DocumentRoot /www/otherdomain
</VirtualHost>

答案 1 :(得分:0)

使用Virtual Hostssamples

NameVirtualHost *:80
<VirtualHost *:80>
    ServerName www.domain1.com
    DocumentRoot /usr/local/apache/htdocs1
</VirtualHost>
<VirtualHost *:80>
    ServerName www.domain2.com
    DocumentRoot /usr/local/apache/htdocs2
</VirtualHost>