& url 中的符号编码为 %2526
我需要替换 & 的编码值登录我的网址,以便搜索查询成功。我正在努力从这篇帖子 用于如下查询字符串。
lovelakedistrict.com/result/?q=Brookfield+Bed+%2526+Breakfast
我希望它像这样
lovelakedistrict.com/result/?q=Brookfield+Bed+&+Breakfast
原因是带有 % 的 url 2526 在 google 中有索引,显然已损坏。
I need to replace the encoded value for the & sign in my url so the search query is successful. Im struggling to copy a similar method from the solution in this post for a query string such as below.
lovelakedistrict.com/result/?q=Brookfield+Bed+%2526+Breakfast
I want it to be like so
lovelakedistrict.com/result/?q=Brookfield+Bed+&+Breakfast
The reason being is that the url with the %2526 is indexed in google and is obviously broken.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
正如aularon所说,它应该是
Bed+%26+Breakfast
,因为&
是查询字符串参数分隔符。 (您会注意到,如果您点击第二个链接,您实际上正在搜索“Brookfield Bed”。)结果是正确的查询,例如:
但是,由于
/result
是文件夹中,Web 服务器将该查询重定向到/result/
,并且出于某种原因同时更改查询字符串,将其双重编码为%2526
。我不知道为什么它会这样做,这不是正常的 Apache 行为——也许你有一些狡猾的重写规则?——但你应该能够通过将表单指向正确的 URL 来避免它:
As aularon said, it should be
Bed+%26+Breakfast
, as&
is a query string parameter separator. (You'll notice if you follow the second link you are actually searching for “Brookfield Bed ”.)Results in a correct query like:
However, since
/result
is a folder, the web server redirects that query to/result/
, and for some reason changes the query string at the same time, double-encoding it to%2526
.I don't know why it does that, it's not normal Apache behaviour—have you got some dodgy rewrite rules maybe?—but you should be able to avoid it by pointing the form at the proper URL:
(从您发布的链接复制,将
20
更改为26
)(copied from the link you posted changing
20
s into26
s)