
我知道如何在 apache httpd.conf 檔案中設定多個主機,但是否可以使其動態化。
如果我將資料夾放在這樣的目錄中。
c:\
development\
websites\
SiteA
SiteB
SiteC
我可以用這樣的方式寫我的 httpd.conf 檔案嗎
<VirtualHost *:80>
ServerName *.example.com
DocumentRoot "c:/development/Websites/%1/"
</VirtualHost>
其中%1
或其他變數標記是 SiteA(如果使用者造訪 sitea.example.com 等)或事件(如果 siteA 必須是完全限定的網域就可以了)。
答案1
答案2
至少在 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