【发布时间】:2016-12-18 11:17:24
【问题描述】:
我想重定向以下域
http://example.com
http://www.example.com
https://example.com
到
https://www.example.com
在单个 http 请求中
我知道它可以在两个请求中使用
#First rewrite any request to the wrong domain to use the correct one (here www.)
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
#Now, rewrite to HTTPS:
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
但是额外的重定向会增加页面的加载时间。
我想在一个 http 请求中做这两件事
我在 ubuntu 上使用 apache2
提前致谢
【问题讨论】:
标签: apache .htaccess http redirect https