我在其中一個域中遇到類似問題。我有裸露和www域的安裝SSL證書。.htaccess將赤裸http和https重定向到www https
現在,但是我想將裸體http://domain.com和https://domain.com重定向到https://www.domain.com。
我在我的.htaccess這個規則,但它涵蓋了重定向,當您訪問的網站明確與https://domain.com,但是,參觀http://domain.com時,重定向到http://www.domain.com代替https://www.domain.com。
RewriteCond %{HTTP_HOST} ^[^.]+\.[^.]+$
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule^http%1://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
如果URL是通過'http:// example.com'那麼這個片段將做兩個重定向,這是不利於無論是性能還是SEO – anubhava
總是在學習,感謝您的輸入@anubhava。必須改變我的方法:P – Lag
在第一條規則中使用https並避免雙重重定向。切勿使用['R = 301']進行測試(http://stackoverflow.com/a/9204355/1741542)。 –