& url 中的符号编码为 %2526

发布于 2024-09-18 08:54:52 字数 376 浏览 2 评论 0原文

我需要替换 & 的编码值登录我的网址,以便搜索查询成功。我正在努力从这篇帖子 用于如下查询字符串。

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

柒夜笙歌凉 2024-09-25 08:54:52

正如aularon所说,它应该是Bed+%26+Breakfast,因为&是查询字符串参数分隔符。 (您会注意到,如果您点击第二个链接,您实际上正在搜索“Brookfield Bed”。)

<form id="form" action="/result" method="get">

结果是正确的查询,例如:

http://www.lovelakedistrict.com/result?q=Brookfield+Bed+%26+Breakfast

但是,由于 /result 是文件夹中,Web 服务器将该查询重定向到 /result/,并且出于某种原因同时更改查询字符串,将其双重编码为​​ %2526

我不知道为什么它会这样做,这不是正常的 Apache 行为——也许你有一些狡猾的重写规则?——但你应该能够通过将表单指向正确的 URL 来避免它:

<form id="form" action="/result/" method="get">

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 ”.)

<form id="form" action="/result" method="get">

Results in a correct query like:

http://www.lovelakedistrict.com/result?q=Brookfield+Bed+%26+Breakfast

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:

<form id="form" action="/result/" method="get">
め可乐爱微笑 2024-09-25 08:54:52
RewriteCond %{QUERY_STRING} (.*?)%(25)+26(.*?%(25)+26.*)
RewriteRule ^ %{REQUEST_URI}?%1+%3 [N]
RewriteCond %{QUERY_STRING} (.*?)%(25)+26(.*)
RewriteRule ^ %{REQUEST_URI}?%1+%3 [L,R=301]

(从您发布的链接复制,将 20 更改为 26

RewriteCond %{QUERY_STRING} (.*?)%(25)+26(.*?%(25)+26.*)
RewriteRule ^ %{REQUEST_URI}?%1+%3 [N]
RewriteCond %{QUERY_STRING} (.*?)%(25)+26(.*)
RewriteRule ^ %{REQUEST_URI}?%1+%3 [L,R=301]

(copied from the link you posted changing 20s into 26s)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文