Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.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 mod_将http重写为https重定向适用于www.example.com/index.html,但不适用于www.example.com/_Apache_.htaccess_Mod Rewrite - Fatal编程技术网

Apache .htaccess mod_将http重写为https重定向适用于www.example.com/index.html,但不适用于www.example.com/

Apache .htaccess mod_将http重写为https重定向适用于www.example.com/index.html,但不适用于www.example.com/,apache,.htaccess,mod-rewrite,Apache,.htaccess,Mod Rewrite,我正在尝试在我的网站上设置http到https重定向,该网站由使用SNI扩展的共享主机提供商提供服务。这是他们对my.htaccess文件的建议修改: RewriteEngine On RewriteCond %{HTTP:X-Forwarded-Proto} !https RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] 我的问题是,当我导航到时,我被正确重定向到。但是,导航到不会导致重定向 %{REQUEST_URI}的

我正在尝试在我的网站上设置http到https重定向,该网站由使用SNI扩展的共享主机提供商提供服务。这是他们对my.htaccess文件的建议修改:

RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
我的问题是,当我导航到时,我被正确重定向到。但是,导航到不会导致重定向


%{REQUEST_URI}的使用是否会阻止它在域后没有路径的情况下工作?要使重定向正常工作,我应该做哪些修改?

这应该可以。您也可以尝试:重写规则^https://%{HTTP\u HOST}%{REQUEST\u URI}[L,R=301]并将此规则保留为第一条规则。感谢您让我返回并检查!一定有东西被缓存了或者还没有传播回去,现在看,一切正常。