1
我想將http重定向到https和www到非www。http到https,www到非www和尊重url
案例:
http://example.com/my/url
http://www.example.com/my/url
https://example.com/my/url
https://www.example.com/my/url
結果
https://example.com/my/url
https://example.com/my/url
https://example.com/my/url
https://example.com/my/url
我現在的htaccess文件:
RewriteCond %{HTTP_HOST} ^www\.(.+) [NC]
RewriteRule ^(.*) https://%1/$1 [R=301,NE,L]
RewriteCond %{HTTPS} off
RewriteRule^https://%{HTTP_HOST}%{REQUEST_URI} [NE,L,R=301]
問題:
它重定向到https://example.com/index.php。
我想讓它尊重網址https://example.com/my/url。
我發現很多問題,但我還沒有找到完整的解決方案。事實上,上面的htaccess代碼是唯一能夠像10次嘗試一樣運行良好的代碼。
很高興擁有一切規則。我認爲解決辦法是把它放在任何其他規則之前。謝謝! –