Hello!
I'd like to rewrite requests with or without a slash on the end by a rewrite map. Here are the relevant config lines.
map $in $out {
/path1/ /target1/;
/path2/ /target2/;
...
};
server {
...
set $in $request_uri;
if ($out) { rewrite ^ $out permanent; } # this works
set $in "${request_uri}/";
if ($out) { rewrite ^ $out permanent; } # this does not
...
}
This way "GET /path1" and GET /path1/" both should be redirected to /target1/, by either the first or the second assigment. The second does not work though. What's the catch?
Nginx 1.4.1
Bests,
Andor
I'd like to rewrite requests with or without a slash on the end by a rewrite map. Here are the relevant config lines.
map $in $out {
/path1/ /target1/;
/path2/ /target2/;
...
};
server {
...
set $in $request_uri;
if ($out) { rewrite ^ $out permanent; } # this works
set $in "${request_uri}/";
if ($out) { rewrite ^ $out permanent; } # this does not
...
}
This way "GET /path1" and GET /path1/" both should be redirected to /target1/, by either the first or the second assigment. The second does not work though. What's the catch?
Nginx 1.4.1
Bests,
Andor