我怎样才能创建像 *.example.com 这样的动态虚拟主机?
How can I create dynamic virtual hosting like *.example.com?
其中 * 对于每个客户都是不同的,例如 apple.example.com、pearl.example.com。
这些都应该路由到相同的 IP 和相同的目录。
如何修改hosts文件和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 中使用星号:
<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>
其中 * 对于每个客户都是不同的,例如 apple.example.com、pearl.example.com。 这些都应该路由到相同的 IP 和相同的目录。 如何修改hosts文件和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 中使用星号:
<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>