Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NGINX / Apache RewriteMap

I would like to know how to translate Apache "RewriteMap" directives in NGINX.

I've found nothing in the NGINX online documentation

My current apache code is:

RewriteMap map-one txt:C:/map-one.txt
RewriteMap map-two txt:C:/map-two.txt

<Directory /> 
    Options All 
    AllowOverride All
    RewriteEngine On
    RewriteRule /MYSITE/PRODUCT/([A-Za-z0-9-]+)/([A-Za-z0-9-]+),([0-9]+).aspx /$1/$2/${map-two:$3}/${map-one:$3} [R=301,L]
</Directory> 

Any Idea ?

like image 658
Caleb2000 Avatar asked Dec 05 '25 23:12

Caleb2000


1 Answers

Check Nginx HTTP Map Module

map $uri $new {
  default               http://www.domain.com/home/;

  /aa                   http://aa.domain.com/;
  /bb                   http://bb.domain.com/;
  /john                 http://my.domain.com/users/john/;
}
like image 56
karlcow Avatar answered Dec 08 '25 14:12

karlcow