這個賞金已經結束。此問題的答案有資格獲得 100聲望賞金。賞金寬限期在21 小時后結束。 林法勇想引起更多的關注。
我在本地機器(mac-os monterrey)上運行 brew/apache。
我想配置虛擬主機。
對其中一個虛擬主機 (panierssaison.local) 的查找不起作用,延遲幾秒鐘后出現服務器未找到錯誤。
Apache 設定為監聽 8080 埠,httpd.conf 中允許虛擬主機
這是 httpd-vhosts.conf 中問題主機的配置:
<VirtualHost *:8080>
ServerAdmin [email protected]
DocumentRoot "/Users/eniac314/Sites/paniersSaison"
ServerName panierssaison.local
ServerAlias www.panierssaison.local
ErrorLog "/opt/homebrew/var/log/httpd/panierssaison.local-error_log"
CustomLog "/opt/homebrew/var/log/httpd/panierssaison.local-access_log" common
<Directory "/Users/eniac314/Sites/paniersSaison">
Options Indexes FollowSymLinks Multiviews
MultiviewsMatch Any
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
我像這樣在hosts.conf中添加了虛擬主機
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost panierssaison.local laterreduchat.local murol.local
255.255.255.255 broadcasthost
::1 localhost
未加載的站點使用 /Users/eniac314/Sites/paniersSaison 中的 .htaccess 檔案,洗掉它允許站點加載。
.htaccess 相關規則:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteBase /
[..]
運行 httpd -S 時,所有虛擬主機都被正確檢測到。
uj5u.com熱心網友回復:
所以似乎在 hosts.conf 中添加帶有 www 前綴的服務器別名解決了這個問題。
這是我的 hosts.conf 現在:
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost panierssaison.local laterreduchat.local murol.local www.panierssaison.local www.laterreduchat.local www.murol.local
255.255.255.255 broadcasthost
::1 localhost
我認為 .htaccess 中的這條規則
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
將 www 前綴附加到 url,防止 dns 匹配。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/467182.html
