Welcome! Log In Create A New Profile

Advanced

Use rewrite map twice

Posted by andor.toth 
Use rewrite map twice
May 28, 2013 08:34AM
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



Edited 1 time(s). Last edit at 05/28/2013 08:35AM by andor.toth.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 162
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready