代码之家  ›  专栏  ›  技术社区  ›  AJFMEDIA

加号被替换为%252520

  •  0
  • AJFMEDIA  · 技术社区  · 16 年前

    有人知道为什么吗?

    例子:

    lovelakedistrict.com/result/?q=Private%252520car%252520park&page=2
    

    应该是

    lovelakedistrict.com/result/?q=Private+car+park&page=2
    

    我听说这是一个结果重定向我的网址在htaccess?

    2 回复  |  直到 16 年前
        1
  •  3
  •   Gumbo    16 年前

    如果URI查询中使用了空格,则必须将其替换为 %20 percent encoding )或者 + application/x-www-form-urlencoded content type 表格)。在你的例子中,数据似乎被编码了三次( % 是用 %25 ).

    + :

    RewriteCond %{QUERY_STRING} (.*?)%(25)+20(.*?%(25)+20.*)
    RewriteRule ^ %{REQUEST_URI}?%1+%3 [N]
    RewriteCond %{QUERY_STRING} (.*?)%(25)+20(.*)
    RewriteRule ^ %{REQUEST_URI}?%1+%3 [L,R=301]
    
        2
  •  2
  •   Déjà vu    16 年前

    事实上 %25 是 % 烧焦, %20

    http://www.lovelakedistrict.com/result/?q=Private car park&page=2 =>
    http://www.lovelakedistrict.com/result/?q=Private%20car%20park&page=2 =>
    http://www.lovelakedistrict.com/result/?q=Private%2520car%2520park&page=2 =>
    http://www.lovelakedistrict.com/result/?q=Private%252520car%252520park&page=2
    

    如你所见,一个 编码为 %25
    所以第一次,你 空间,然后你得到一个 %25 对于 % %20 接着是 20 ,然后,同样的编码。