Opened 9 years ago

Last modified 7 years ago

#644 reopened defect

nginx rewrite $uri not right

Reported by: caoyu Owned by:
Priority: major Milestone:
Component: nginx-module Version: 1.4.x
Keywords: Cc:
uname -a: Linux hathor237 2.6.32-358.el6.x86_64 #1 SMP Fri Feb 22 00:31:26 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
nginx -V: nginx version: nginx/1.4.4
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-3) (GCC)
TLS SNI support enabled
configure arguments: --prefix=/usr/local/sinasrv2 --sbin-path=/usr/local/sinasrv2/sbin/nginx --conf-path=/usr/local/sinasrv2/etc/nginx.conf --lock-path=/usr/local/sinasrv2/var/logs/nginx.lock --pid-path=/usr/local/sinasrv2/var/run/nginx.pid --error-log-path=/usr/local/sinasrv2/var/logs/nginx.error.log --http-log-path=/usr/local/sinasrv2/var/logs/nginx.access.log --http-client-body-temp-path=/usr/local/sinasrv2/var/nginx/client_body_temp --http-proxy-temp-path=/usr/local/sinasrv2/var/nginx/proxy_temp --http-fastcgi-temp-path=/usr/local/sinasrv2/var/nginx/fastcgi_temp --without-select_module --without-poll_module --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_xslt_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_stub_status_module --add-module=/data0/rpmbuild/build/lua-nginx-module-0.9.2 --add-module=/data0/rpmbuild/build/ngx_devel_kit-0.2.18 --add-module=/data0/rpmbuild/build/redis2-nginx-module-0.10 --add-module=/data0/rpmbuild/build/echo-nginx-module-0.45 --add-module=/data0/rpmbuild/build/nginx_upstream_check_module-0.1.10 --add-module=/data0/rpmbuild/build/nginx-upstream-fair-0.1 --add-module=/data0/rpmbuild/build/nginx-sticky-module-1.2

Description

request is "/test?a=1"

when

rewrite ^/test /t.php/test?a=1 last;

then $uri is "/t.php/test" which is right.

when

rewrite ^/test /t.php$request_uri last;

then $uri is "/t.php/test?a=1" which is not right.

Change History (5)

comment:1 by Maxim Dounin, 9 years ago

Resolution: invalid
Status: newclosed

The $request_uri variable contains Request-URI from Request-Line as per RFC 2616, unmodified, and it is expected to include arguments. It is documented here.

in reply to:  1 comment:2 by caoyu, 9 years ago

Replying to Maxim Dounin:

The $request_uri variable contains Request-URI from Request-Line as per RFC 2616, unmodified, and it is expected to include arguments. It is documented here.

I said $uri include arguments that is wrong, not $request_uri

comment:3 by Maxim Dounin, 9 years ago

Resolution: invalid
Status: closedreopened

Ah, ok, I see. You mean that $uri is "/t.php/test?a=1" and args is "" instead of $uri "/t.php/test" and args "a=1". This probably needs fixing, yes.

comment:4 by yohan.rizk@…, 7 years ago

Is this still an issue? I'm on ngx version 1.11.8 and I'm looking right at the parsing logic in ngx_http_parse.c line 1475 . it looks like uri stops at the right place and args gets populated instead. I can go through the tests or try and recreate the situation, but if this is just a matter of a ticket forgot to be closed I'd rather find out sooner than later. thank you

comment:5 by Maxim Dounin, 7 years ago

This ticket is about the rewrite directive, not about generic URI parsing you are looking into. It still applies.

Note: See TracTickets for help on using tickets.