重写没有转义输出

时间:2015-05-10 16:43:21

标签: nginx escaping rewrite

我移植了我的"画廊"现在在我的nginx而不是apache后面运行。 "一切正常"除了以下重定向:

rewrite ^/gallery2/v/([^\?]+)$ /gallery2/main.php?g2_path=$1 last;

这通常有效,我的nginx日志显示它适用于大多数电话:

2015/05/10 12:27:43 [notice] 22192#0: *40455
          "^/gallery2/v/([^\?]+)$" matches "/gallery2/v/rolf/Shortlist/AAAMFL/",
          client: 192.168.a.b, server: example.com,
          request: "GET /gallery2/v/rolf/Shortlist/AAAMFL/ HTTP/1.1",
          host: "example.com",
          referrer: "https://example.com/gallery2/v/rolf/Shortlist/"
2015/05/10 12:27:43 [notice] 22192#0: *40455
          rewritten data: "/gallery2/main.php",
          args: "g2_path=rolf/Shortlist/AAAMFL/",
          client: 192.168.a.b, server: example.com,
          request: "GET /gallery2/v/rolf/Shortlist/AAAMFL/ HTTP/1.1",
          host: "example.com",
          referrer: "https://example.com/gallery2/v/rolf/Shortlist/"

问题是我有几张专辑'在他们的名字中有空格。在这些情况下,我得到以下内容:

2015/05/10 12:33:02 [notice] 22191#0: *40489
          "^/gallery2/v/([^\?]+)$" matches "/gallery2/v/rolf/Shortlist/calendar+2013/",
          client: 192.168.a.b, server: example.com,
          request: "GET /gallery2/v/rolf/Shortlist/calendar+2013/ HTTP/1.1",
          host: "example.com",
          referrer: "https://example.com/gallery2/v/rolf/Shortlist/"
2015/05/10 12:33:02 [notice] 22191#0: *40489
          rewritten data: "/gallery2/main.php",
          args: "g2_path=rolf/Shortlist/calendar%2b2013/",
          client: 192.168.a.b, server: example.com,
          request: "GET /gallery2/v/rolf/Shortlist/calendar+2013/ HTTP/1.1",
          host: "example.com",
          referrer: "https://example.com/gallery2/v/rolf/Shortlist/"

当网址有空格时,浏览器会使用+对其进行编码,并请求:/gallery2/v/rolf/Shortlist/calendar+2013/,其重写基本上为:/gallery2/main.php?g2_path=rolf/Shortlist/calendar%2b2013/

上述重写失败,内部PHP错误无法找到资源....我可以通过浏览器显示,并且如果我没有逃避{{1} } +,它的工作原理.....

换句话说,完整的网址:

%2b

有效,但以下情况并非如此:

/gallery2/main.php?g2_path=rolf/Shortlist/calendar+2013/

那么,在我的重写规则中,如何告诉nginx不要逃避/gallery2/main.php?g2_path=rolf/Shortlist/calendar%2b2013/

提醒一下,这是我的规则:

+

0 个答案:

没有答案