我的虛擬主機檔案:
<VirtualHost *:80>
ServerName localhost
ServerAlias localhost
DocumentRoot "C:/wamp64/www/"
<Directory "C:/wamp64/www/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
和專案虛擬主機:
<VirtualHost *:80>
ServerName www.tour.test
DocumentRoot "C:/wamp64/tour/public"
SetEnv APPLICATION_ENV "development"
<directory "C:/wamp64/tour/public">
DirectoryIndex index.php
AllowOverride all
Order Allow,Deny
Allow from all
</directory>
</VirtualHost>
答案1
假設我沒有誤解你的問題,有兩個可能的罪魁禍首:
您忘記在本地地址末尾添加尾部斜杠(例如,它應該http://example.test/在瀏覽器中,不是http://example.test)。
你沒有域名系統為本地域正確設定(例如
*.test
)。
關於尾部斜杠,這是當前版本的 Chrome、Firefox 和 Opera 本地域所必需的(儘管localhost
不需要這種處理)。
關於 ServerName/ServerAlias 指令還有兩個小問題:
您的
localhost
條目實際上並不需要該ServerAlias localhost
指令。您的
www.tour.test
主機條目應該(可以說)以如下方式開頭:ServerName tour.test
ServerAlias www.tour.test, *.tour.test