![](/img/trans.png)
[英]Adding Apache VirtualHost, DocumentRoot of localhost changes to the VirtualHost's DocumentRoot
[英]VirtualHost in Apache 2.4 replaces DocumentRoot when using http://localhost
我正在使用Yosemite和Apache 2.4
/private/etc/apache2/httpd.conf
ServerName 127.0.0.1:80
DocumentRoot "/Library/WebServer/Documents/"
<Directory "/Library/WebServer/Documents">
Options Multiviews FollowSymLinks
MultiviewsMatch Any
AllowOverride All
Order allow,deny
Allow from all
</Directory>
一切都很好, http://localhost
將我指向默認的/Library/WebServer/Documents/index.html
將Include /private/etc/apache2/extra/httpd-vhosts.conf
添加到/private/etc/apache2/httpd.conf后
並將以下配置添加到/private/etc/apache2/extra/httpd-vhosts.conf
<VirtualHost *:80>
ServerAdmin admin@xxx.com
ServerName xxx.local
DocumentRoot "/Library/WebServer/Documents/xxx"
<Directory "/Library/WebServer/Documents/xxx/">
Options +FollowSymLinks
AllowOverride all
Require all granted
</Directory>
</VirtualHost>
當從瀏覽器使用http://localhost
和http://127.0.0.1
,Apache將我引導到/Library/WebServer/Documents/xxx/index.html而不是/Library/WebServer/Documents/index.html ,怎么能我修好了嗎?請指導。
謝謝。
我今天遇到了同樣的問題。
主要人物消失了
任何與現有服務器不匹配的請求都由全局服務器配置處理,無論主機名或ServerName如何。
將基於名稱的虛擬主機添加到現有服務器,並且虛擬主機參數與預先存在的IP和端口組合匹配時,請求現在將由顯式虛擬主機處理。 在這種情況下,通常明智的做法是創建一個ServerName與基本服務器匹配的默認虛擬主機。 然后,可以將相同接口和端口上的新域(但需要單獨的配置)添加為后續(非默認)虛擬主機。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.