Hello!
2012/8/8 Carl wrote:
> 很早就看过你的nginx教程。由于自己还是个新手,特地来请教一个问题。就是关于nginx跳转时候的转义问题,
> 以前用的是Apache+tomcat,这次把Apache转到nginx下,原来的rewrite规则出先了一点问题
> 例如:
>
> http://xxx.com/a+b/c.html?a=1&b=2
> 在经过nginx后+和& 都转义成%2B之类的的了,导致在tomcat下不能解析。
> 用的是如下配置
> location ~* ^/wholesale/([^/]*).shtml(.*)$ {
> proxy_pass http://.xxx.com;
> # rewrite ^/wholesale/([^/]*).shtml(.*)$
> /search,products_list.vm?keywords=$1&$2 break;
> rewrite ^/wholesale/(.*)\+(.*).shtml(.*)$
> /search,products_list.vm?keywords=$1&$2 break;
> }
> 以前Apache下没有这样的问题。网上查了下资料,没看到有这样的问题出现,所以来求助一下。
>
+ 和 & 在 URI 中都是有特殊含义的,所以在任何一个环节都有可能被转义。建议不要滥用这样的特殊字符,同时你在后端服务器中应该总是先进行 URI 反转义。
另外,你给的示例 URI 和你的配置不一致,你的示例 URI 既不是以 /search,products_list.vm 起始的,也不是以
/wholesale/ 起始的。
同时抄送给 openresty 邮件列表:https://groups.google.com/group/openresty
也欢迎你在那里和更多的 nginx 用户交流讨论。
Best regards,
-agentzh