外部链接 URL 编码导致 Nginx 服务器上的“%3F"和“%3D" [英] External links URL encoding leads to '%3F' and '%3D' on Nginx server

查看:26
本文介绍了外部链接 URL 编码导致 Nginx 服务器上的“%3F"和“%3D"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的服务器有问题.我有四个指向我的动态网页不同站点的入站链接,它们看起来像这样:

I got a problem with my server. I got four inbound links to different sites of my dynamic webpage which look something like this:

myurl.com/default/Site%3Fid%3D13

它们应该是这样的:

myurl.com/default/Site?id=13

我知道那些 %3F? 符号的转义序列,而 %3D 是等号的转义序列符号.但是当我使用这些链接时,我确实收到了错误 400.我该怎么办?

I do know that those %3F is an escape sequence for the ? sign and the %3D is an escape sequence for the equal sign. But I do get an error 400 when I use those links. What can I do about that?

这四个链接是针对不同网站的,我想随着时间的推移会有更多这样的链接.因此,一个解决方案将是完美的.

The four links are for different sites, and I imagine over time there will be more links like that. So one fix for all would be perfect.

推荐答案

一个完全相同的问题实际上在一年前在 nginx-ru 邮件列表上被问到:

An exact same question was actually asked on nginx-ru mailing list about a year ago:

http://mailman.nginx.org/pipermail/nginx-ru/2013-February/050200.html

最有帮助的回复,来自 Nginx, Inc,员工/开发人员,Валентин Бартенев:

The most helpful response, by an Nginx, Inc, employee/developer, Валентин Бартенев:

http://mailman.nginx.org/pipermail/nginx-ru/2013-February/050209.html

Если запрос приходит в таком виде, то это уже не параметры, а имя запрошенногофайла.Другое дело, что location ищется по уже раскодированному адресу, о чем вдокументации написано.

Если запрос приходит в таком виде, то это уже не параметры, а имя запрошенного файла. Другое дело, что location ищется по уже раскодированному адресу, о чем в документации написано.

翻译:

如果请求以这种形式出现,那么这些不再是参数,而是请求文件的名称.另一件事是,如文档所述,位置匹配是针对规范化的 URI 执行的.

If the request comes in such a form, then these are no longer the args, but the name of the requested file. Another thing is that, as documented, the location matching is performed against a normalised URI.

他建议的解决方案,从这里的问题转换为示例示例,然后将是:

His suggested solution, translated to the sample example from the question here at SO, would then be:

location /default/Site? {
    rewrite ?(.*)$ /default/Site?$1? last;
}

location = /default/Site {
    [...]
}

这篇关于外部链接 URL 编码导致 Nginx 服务器上的“%3F"和“%3D"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆