【发布时间】:2016-01-26 03:25:38
【问题描述】:
我正在尝试让我的所有 URL 重定向到 https:// 而没有 www.
如果有人输入www. 或http:// 或http://,他们会被重定向到https://,如果他们输入https://www.,那么问题就来了,那么它不会重定向到https://website
我在htaccess 中使用以下内容,有什么建议吗?
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
【问题讨论】:
-
没有多大意义。
if (https is off and the host has www) then redirect,后跟if (https is not on, aka it's off) then redirect。