Nginx Map Multiple Parameter Input

Igor Sysoev igor at sysoev.ru
Fri Oct 12 12:56:46 UTC 2012


On Oct 12, 2012, at 16:26 , rahul286 wrote:

> 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!

What version do you use ?

Changes with nginx 0.9.0                                         29 Nov 2010

       ...

    *) Feature: the "map" directive supports expressions as the first
       parameter.


--
Igor Sysoev
http://nginx.com/support.html



More information about the nginx mailing list