![](/img/trans.png)
[英]Magento, redirect the url from “www.domain.com/home” to base url “www.domain.com”
[英]redirect a url or domain with www
我有一個關於url或域重定向的簡單問題。 我一直在尋找有關如何將url或域從http重定向到http以強制使用ssl的問題。
當我嘗試不重定向任何www時,出現了一個奇怪的部分。 前往www。 與域。 我嘗試了很多方法,但是沒有一種方法對我有用。 有誰知道為什么嗎? 以及如何解決這個問題?
這是我在.htaccess中使用的代碼:
RewriteCond %{HTTP_HOST} ^mydomain\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.mydomain\.com$
RewriteRule ^/?$ "https\:\/\/www\.mydomain\.com\/main" [R=301,L]
另一個奇怪的事情是,每當我在沒有www的瀏覽器中鍵入域時。 有錯誤消息,但是當我插入www時。 在域的前面,它當然使用https和wwww重定向。
任何想法?
謝謝
您的規則將陷入循環。 改為這樣做:
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.