【发布时间】:2014-08-02 14:45:19
【问题描述】:
我正在使用单个域证书(仅在 www. 子域上)并且希望所有用户都使用它。
目前我的 htaccess 文件中有以下内容:
## force HTTPS and www. if any of them are not already present
RewriteCond %{HTTP_HOST} (?!^www\.)^(.+)$ [OR]
RewriteCond %{HTTPS} off
RewriteRule ^ https://www.%1%{REQUEST_URI} [R=301,L]
但问题是,这似乎导致了两个单独的重定向:
http://domain.com -> https://domain.com -> https://www.domain.com
这意味着用户需要 3 个 RTT,直到他到达正确的页面。此外,只有第二个重定向似乎是永久的,第一个(http 到 https)似乎是临时的,
有没有直接将http请求发送到https+www的解决方案?
提前非常感谢!
【问题讨论】:
标签: apache .htaccess mod-rewrite redirect