其中 * 对于每个客户端都不同,例如 apple.example.com、pearl.example.com。这些都应该路由到相同的 IP 和相同的目录。如何修改主机文件和 httpd 配置?
更详细的示例:
<VirtualHost 111.22.33.44>
ServerName customer-1.example.com
DocumentRoot "/www/hosts/example.com/docs"
ScriptAlias "/cgi-bin/" "/www/hosts/example.com/cgi-bin"
</VirtualHost>
<VirtualHost 111.22.33.44>
ServerName customer-2.example.com
DocumentRoot "/www/hosts/example.com/docs"
ScriptAlias "/cgi-bin/" "/www/hosts/example.com/cgi-bin"
</VirtualHost>
<VirtualHost 111.22.33.44>
ServerName customer-N.example.com
DocumentRoot "/www/hosts/example.com/docs"
ScriptAlias "/cgi-bin/" "/www/hosts/example.com/cgi-bin"
</VirtualHost>
谢谢!
您可以在 ServerAlias 中使用 star,如下所示:
<VirtualHost 111.22.33.44>
ServerName customer-1.example.com
ServerAlias *.example.com
DocumentRoot "/www/hosts/example.com/docs"
ScriptAlias "/cgi-bin/" "/www/hosts/example.com/cgi-bin"
</VirtualHost>