This worked for me in a quick test: map $request_uri $request_path { ~(?<captured_path>[^?]*) $captured_path; } Posted at Nginx Forum: http://forum.nginx.org/read.php?2,227612,230275#msg-230275