Nginx Map Multiple Parameter Input

rahul286 nginx-forum at nginx.us
Fri Oct 12 12:26:38 UTC 2012


I have a case where I need to use Nginx map in slightly different way.

I use following to create a variable $blogpath


`map $uri $blogname{
        ~^(?P<blogpath>/[_0-9a-zA-Z-]+/)files/(.*)       $blogpath ;
}`

Next, I want to run another map using:


`map $http_host$blogpath $blogid{
            #map lines
}`


Problem is - map doesn't support 2 input parameters. It throws error:
"nginx: [emerg] invalid number of the map parameters ..."

As map is outside server{] block, I cannot use set to create a temporary
variable to combine value of "$http_host$blogpath"

Goal is to get "domain-name.com/first-dir" from URL. If any other nginx
variable can give me entire URL as seen in browser, it will also work. 

Please suggest a workaround!

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,231715,231715#msg-231715



More information about the nginx mailing list