【问题标题】:Apache2 rewrite with query string escaped twiceApache2重写查询字符串转义两次
【发布时间】:2011-09-10 05:28:39
【问题描述】:

在虚拟主机配置文件中使用此规则会导致查询参数的双重转义:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

例如:

http://example.com?f=hello%20world

导致

https://example.com?f=hello%2520world

注意转义“%”符号的“%25”。为什么会这样?

【问题讨论】:

    标签: apache mod-rewrite query-string


    【解决方案1】:

    尝试在重写规则末尾添加[NE](noescape)标签:

    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [NE]
    

    发生这种情况是因为&? 以及其他一些在重写过程中默认被转义。

    【讨论】:

      猜你喜欢
      • 2011-02-01
      • 2011-08-02
      • 2011-04-07
      • 2010-11-16
      • 2012-01-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多