2011-07-07 84 views

回答

0

嘗試做它喜歡...

NameVirtualHost *:80 

<VirtualHost *:80> 
    DocumentRoot = /var/www/dir1 
    ServerName d1.example.com 
<VirtualHost> 

<VirtualHost *:80> 
    DocumentRoot = /var/www/example 
    ServerName example.com 
<VirtualHost> 

<VirtualHost *:80> 
    DocumentRoot = /var/www/someotherdir 
    ServerName other.example.com 
    ServerAlias *.example.com 
<VirtualHost> 

從我的工作設置兩者(顯然修剪一點點!)

+0

<虛擬主機*:80> 的DocumentRoot = /無功/網絡/通配符 服務器名other.example.com ServerAlias * .example.com的 這是行不通的。這只是for other.example.com。當我瀏覽aaaa.example.com時,正在從/ var/www/wildcard加載內容表單/ var/www/example – Petter

+0

編輯我的示例... – Brian

0

試試這個,你可以使用apachelocation指令強制目錄 - 根

<VirtualHost *:80> 
    ServerName example.com 
    ServerAlias www.example.com 
    DocumentRoot /var/www/dir1 
<VirtualHost> 

<VirtualHost *:80> 
    ServerName *.example.com 
    DocumentRoot /var/www/dir2 
<VirtualHost> 

記得第VirtualHost優先。