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

查看:645
本文介绍了外部链接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 ищется по уже раскодированному адресу, о чем в документации написано.

翻译:

如果请求以这种形式出现,则这些不再是args,而是请求文件的名称.另一件事是,如所记录的那样,位置匹配是针对标准化的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.

他的建议解决方案将被翻译为SO问题的示例示例,

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天全站免登陆