Quantcast
Channel: Nginx Forum - How to...
Viewing all articles
Browse latest Browse all 4759

Use rewrite map twice

$
0
0
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

Viewing all articles
Browse latest Browse all 4759

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>