通过SSL避免着陆页重定向

我最近对我的网站做了Google PageSpeed分析,并收到以下消息:

避免登录页面重定向

你的页面有2个重定向。 重定向在页面加载之前引入额外的延迟。

避免以下重定向URL链的着陆页重定向。

http://example.net/

https://example.net/

https://www.example.net/

有什么我可以做的(比如以某种方式修改我的htaccess文件),还是这是一个不可避免的结果?

这是我的htaccess以防万一:

RewriteCond %{HTTPS} off
# First rewrite to HTTPS:
# Don't put www. here. If it is already there it will be included, if not
# the subsequent rule will catch it.
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Now, rewrite any request to the wrong domain to use www.
RewriteCond %{HTTP_HOST} !^www.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

您可以使用OR标志将两个重定向组合成一个

RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www. [NC]
RewriteCond %{HTTP_HOST} ^(www.)?(.*)$ [NC]
RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
链接地址: http://www.djcxy.com/p/81965.html

上一篇: Avoiding Landing Page Redirects with SSL

下一篇: How to insert a new value to a set and erase another at the same time?