Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache 使用htaccess将用户从http重定向到https_Apache_.htaccess_Mod Rewrite - Fatal编程技术网

Apache 使用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

我对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 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]