【发布时间】:2016-10-21 10:25:58
【问题描述】:
我需要为我的网站找到最佳的重写规则...
我有 2 个域 example.it 和 example.com,但我只有 example.com 下的 SSL。
我需要的是:每个用户请求都应该被重定向到 https://www.example.com/...
现在我正在使用这个规则:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?example\.it$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
但如果我输入http://example.com,它会将我重定向到https://example.com,而不是www。
另外,如果我进行 GTMetrix 测试,我会在避免登录页面重定向下获得 F 值:
Avoid landing page redirects for the following chain of redirected URLs.
http://example.it/
http://www.example.com/
https://www.example.com/
我该如何解决?谢谢。
【问题讨论】:
标签: php apache .htaccess redirect mod-rewrite