Plus signs being replaced for %252520

有些话、适合烂在心里 提交于 2019-12-24 08:22:19

问题


When I click on my index'd pages in Google the plus signs in my query string are being replaced (encoded?) for %252520.

Anyone know why?

Example:

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

should be

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

I have heard that this is a result of redirecting my urls in htaccess?


回答1:


If a space is used in the URI query, it must either be replaced by %20 (percent encoding) or by + (application/x-www-form-urlencoded content type for forms). In your case the data seems to be encoded three times (% is encoded with %25).

Try these rules to replace such sequences it with +:

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:


Actually %25 is the % char, %20 is the space. So it seems your URI was encoded three times

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

As you can see, a % is encoded as %25.
So the first time, you get %20 for the space, then you get a %25 for the % of %20 followed with the 20, then, again, same encoding.

There is probably something wrong in the process before the link is provided to Google.



来源:https://stackoverflow.com/questions/3617784/plus-signs-being-replaced-for-252520

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!