![從安全頁面重新導向](https://rvso.com/image/617254/%E5%BE%9E%E5%AE%89%E5%85%A8%E9%A0%81%E9%9D%A2%E9%87%8D%E6%96%B0%E5%B0%8E%E5%90%91.png)
我有 2 個域名,其中一個是https://app.example.com其中配置了 SSL,另一個是http://www.example.com(SSL 是為該網站配置的,之前http://app.example.com沒有配置 SSL)。
問題是當我的用戶錯誤地輸入https://www.example.com這不是啟用 SSL 的網站。用戶將看到我啟用 SSL 的網站的內容。
兩個都https://app.example.com和http://www.example.com位於具有相同 IP 位址的相同伺服器上。
我如何限制應向使用者顯示使用者輸入的網站的內容。 (我知道當使用者造訪我的未啟用 SSL 的網站時,他們將看到 SSL 憑證警告,但這不是問題。)
答案1
mod_rewrite
在這種情況下,該模組應該會有所幫助。您可以嘗試將這些規則放入您的 SSL 虛擬主機定義中:
RewriteEngine On # enable mod rewriting engine
RewriteCond %{HTTPS} on # if is was used
RewriteCond %{HTTP_HOST} ^www\.example\.com [NC] # and if the host is www.example.com
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [L] # then rewrite the url it to http