Apache 使用htaccess将用户从http重定向到https
我对htaccess一点也不熟悉。我需要Htaccess代码,它将http重定向到https。我正在使用以下代码:Apache 使用htaccess将用户从http重定向到https,apache,.htaccess,mod-rewrite,Apache,.htaccess,Mod Rewrite,我对htaccess一点也不熟悉。我需要Htaccess代码,它将http重定向到https。我正在使用以下代码: RewriteEngine On RewriteCond %{HTTPS} !on RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} 但主要问题是,在尝试测试服务器速度时,我得到了以下建议: To speed up page load times for visitors of your site, remove as man
RewriteEngine On
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
但主要问题是,在尝试测试服务器速度时,我得到了以下建议:
To speed up page load times for visitors of your site, remove as many landing page
redirections as possible, and make any required redirections cacheable if possible.
http://xxxx.com/ is a non-cacheable redirect to https://xxxx.com/
那么,如何使其可缓存
http://xxxx.com/ 是指向的不可缓存重定向https://xxxx.com/
错误说明一切。要使其在浏览器中永久缓存,请使用R=301
:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]