我知道如何在apache httpd.conf文件中设置多个主机,但是可以使其成为dynamic的。
如果我把我的文件夹放在这样的目录中。
c:\ development\ websites\ SiteA SiteB SiteC
我可以用这种方式写我的httpd.conf文件吗?
<VirtualHost *:80> ServerName *.example.com DocumentRoot "c:/development/Websites/%1/" </VirtualHost>
其中%1
或其他variables标记是SiteA,如果用户访问sitea.example.com等或事件,如果siteA必须是一个完全合格的域是好的。
很简单: 不 。
DocumentRoot
必须是服务器上的单个目录,并且不允许使用通配符。
您可以通过使用本答案中提到的RewriteRule
语句,但是YMMV来获得您之后的行为。
至less在2.4你可以:
<Macro virty $name> <VirtualHost $name:80> ServerName $name.example.com DocumentRoot "c:/development/Websites/$name/" </VirtualHost> </Macro> Use virty SiteA Use virty SiteB Use virty SiteC