0
我設置了我的.htaccess來重定向來自http://subdomain.domain.com.tld,http://www.subdomain.domain.com.tld和http://域的請求.com.tld /文件夾(包含子域內容的文件夾)到https://subdomain.domain.com.tld,因此我一直在使用subdomain.domain.com.tld的單域SSL證書設置。停止.htaccess重定向到
我的問題是http://domain.com.tld也重定向到https://subdomain.domain.com.tld。我該如何阻止?
RewriteOptions inherit
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^subdomain.domain\.com.tld
RewriteRule ^(.*)$ https://subdomain.domain.com.tld/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^.*$
RewriteRule ^folder$ "https\:\/\/subdomain\.domain\.com\.tld\/" [R=301,L]
謝謝。
好吧,domain.com.tld原地踏步,這是偉大的,但subdomain.domain.com.tld只是去subdomain.domain.com/tld,解決了這個改變 的.com/TLD 到 \ .COM .tld 但得到瀏覽器的重定向錯誤。 注意:我通過替換RewriteCond%{HTTP_HOST}下的代碼編輯了我的.htaccess。 – Domenico
對不起,'/ tld'而不是'.tld',這是我的一個錯字。我還在RewriteConds中適當添加了反斜槓 - 在這種情況下,這不會是一個問題,但在技術上更加正確(請注意,RewriteRule中的域不需要它們,因爲它不執行匹配)。規則旨在取代你所有的原始規則。我不確定最初的'RewriteCond%{HTTP_HOST} .'原本是做什麼的......它只能匹配主機名是單個字符的情況,這絕不是這種情況,所以一定要刪除它。 –
不用擔心,謝謝編輯。雖然我得到「嘗試打開https://subdomain.domain.com.tld/時出現重定向,但從domain.com.tld /文件夾重定向到subdomain.com.tld不起作用。三重檢查,並在多個瀏覽器上。 – Domenico