Apache2自动子域名

我希望apache能够根据我放在/ var / www / subdomains /

我是一个完整的Apache noob。

PS我正在使用Ubuntu 10.10

如果按照Apache文档中简单dynamic虚拟主机的说明操作,就可以完成此操作。

按照虚拟主机的标准惯例,如/var/www/www.subdomain.org/docroot//var/www/www.subdomain.org/cgi-bin ,然后在HTTPconfiguration中添加如下内容。

请注意下面的path如何使用%0 。 这将由HTTP请求中Host:头的内容中使用的服务器名称填充。 您必须使用UseCanonicalName Off才能正常工作。 另外请注意,如果访问者访问“www.example.com”“example.com”,“Host:”是不同的,因此“%0”是不同的,所以您需要符号链接或其他方法告诉Apache /var/www/www.example.com//var/www/example.com/是一回事。

 # get the server name from the Host: header UseCanonicalName Off # this log format can be split per-virtual-host based on the first field LogFormat "%V %h %l %u %t \"%r\" %s %b" vcommon CustomLog logs/access_log vcommon # include the server name in the filenames used to satisfy requests VirtualDocumentRoot /var/www/%0/docs VirtualScriptAlias /var/www/%0/cgi-bin