Hey guys,
I have been trying to use the nginx map module to do some rewrites in
bulk, basically my
map looks something like this:
map $request_body $var {
default no;
~.+.string1 dorw;
~.+.string2 dorw;
…
}
in a location i have the following
if ($var = dorw){
rewrite ^ /home last;
}
I also have a log_format which logs the variable state (and it reports
correct), however
once I enable that if… the $var seems to reset to ‘no’.
Any ideas? This is kind of confusing.
Thanks and any help is much appreciated.
Lou
Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,208914,208914#msg-208914
kamlou
June 22, 2011, 10:48am
#2
Hello!
On Wed, Jun 22, 2011 at 01:06:20AM -0400, kamlou wrote:
…
once I enable that if… the $var seems to reset to ‘no’.
Any ideas? This is kind of confusing.
$request_body isn’t available unless it’s read, and this happens
after rewrite phase where “if” is executed. Therefore testing
$var with “if” will always result in “no” and this result will be
cached for further use.
Maxim D.
kamlou
June 22, 2011, 4:36pm
#3
Thanks Maxim.
Any other way I can accomplish this using the map above? Thanks
Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,208914,209084#msg-209084
kamlou
June 22, 2011, 4:52pm
#4
Also, is there any variable in Nginx that will hold the original URL
(including anchors, like /foo/bar/#get /this/that)?
Thanks
Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,208914,209088#msg-209088
kamlou
June 23, 2011, 5:34am
#5
2011/6/22 kamlou [email protected] :
Also, is there any variable in Nginx that will hold the original URL
(including anchors, like /foo/bar/#get /this/that)?
Browsers do not send anchors (fragments) in their requests to the
server.
kamlou
June 22, 2011, 4:56pm
#6
On 22 Jun 2011 15h51 WEST, [email protected] wrote:
Also, is there any variable in Nginx that will hold the original URL
(including anchors, like /foo/bar/#get /this/that)?
Without args: http://wiki.nginx.org/HttpCoreModule#.24uri
With args: http://wiki.nginx.org/HttpCoreModule#.24request_uri
— appa