Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/24.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
Linux .htaccess重写将http重定向到https的规则将URL中%的转义参数弄乱_Linux_Apache_.htaccess_Ubuntu_Https - Fatal编程技术网

Linux .htaccess重写将http重定向到https的规则将URL中%的转义参数弄乱

Linux .htaccess重写将http重定向到https的规则将URL中%的转义参数弄乱,linux,apache,.htaccess,ubuntu,https,Linux,Apache,.htaccess,Ubuntu,Https,我在.htaccess文件中使用了类似于以下内容的内容,将所有http请求重定向到https: RewriteEngine on RewriteCond %{HTTPS} !=on RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] 这是可行的,除非URL是通过转义参数传递的,例如: http://www.example.com/download.php?go=app%20name 重定向时,它再次被错误地转义到:

我在
.htaccess
文件中使用了类似于以下内容的内容,将所有
http
请求重定向到
https

RewriteEngine on
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
这是可行的,除非URL是通过转义参数传递的,例如:

http://www.example.com/download.php?go=app%20name
重定向时,它再次被错误地转义到:

https://www.example.com/download.php?go=app%2520name
如何解决此问题?

在规则中使用:

RewriteEngine on

RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]

在测试更改之前,请确保清除浏览器缓存。

哦,天哪,我忘了web浏览器缓存。我只花了10分钟就明白了为什么
NE
条件不起作用。然后在底部看到了您的编辑。只是好奇,浏览器缓存是如何影响它的
.htaccess
在服务器上解释,客户端浏览器对此没有概念。如果客户端浏览器从web服务器获取
301
状态,则它会在本地缓存原始URL和重定向的URL。下次您访问或在浏览器中输入原始URL时,它将提供重定向的URL并跳过web服务器的访问。谢谢。出于好奇,是否有一个快捷方式来清除Chrome中一页的缓存?类似于Shift+F5清除CSS缓存。您可以一起尝试
ctrl+R