【发布时间】:2015-01-10 22:13:00
【问题描述】:
我正在尝试将表单 http 重写为 https 并将 www 重写为非 www url。
基本上,如果有人转到http://www.example.com,他们需要被重定向到https://example.com 和所有其他错误网址实例(http://example.com 等)。
我试图通过将建议拼凑在一起来做到这一点:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
RewriteCond %{HTTP_HOST} ^www\.garrysun\.com [NC]
RewriteRule ^(.*)$ https://garrysun.com/$1 [L,R=301]
但是当我在重定向检查器中检查 URL 时,我得到了错误...http://garrysun.com 工作正常并转到 https://garrysun.com 但 http://www.garrysun.com 得到这个:
查看链接:http://www.garrysun.com 重定向类型:301 永久移动 重定向到:https://garrysun.com/https://www.garrysun.com
如何更正我的重写代码?
附: - 我正在使用 OpenCart 1.5.4,并且我在新东西之上还有以下重写代码(不知道它是否会影响任何东西):
RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=feed/google_base [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css)
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]
【问题讨论】:
标签: .htaccess redirect url-rewriting rewrite url-redirection