2010-09-01 60 views
0

当我在Google中点击我的索引的页面时,我的查询字符串中的加号正被替换(编码?)为%252520。加号被替换为%252520

任何人都知道为什么?

例子:

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

应该

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

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

回答

2

如果一个空间在URI查询使用,它必须被由%20percent 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] 
+0

再一次完美的感谢。现货:) – AJFMEDIA 2010-09-01 16:25:35

2

其实%25%焦炭,%20是空间。如此看来你的URI进行编码三次

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
所以第一次,你得到%20的空间,那么你得到%25%%20后跟20,然后,再次,相同的编码。

在向Google提供链接之前,此过程中可能有问题。

+0

谢谢你的回答。现在它更有意义 – AJFMEDIA 2010-09-01 16:27:01