Welcome! Log In Create A New Profile



October 15, 2009 05:34PM
I'm unclear how to mimic the Apache rewrite map using the NginxHttpMapModule.

I've included a map in my nginx.conf file, as so:

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/;

Then have trouble using the map without excuding all other rules in my server configuration. The following rewrites everything, obviously, but couldn't figure out how to get a conditional match wrapped around it or from it:

server {
listen 80;
server_name some.domain.com;
rewrite ^ $new redirect;

root /var/www/web;
index index.php;

access_log /var/log/httpd/nginx_access_log main;
error_log /var/log/httpd/nginx_error_log;

charset utf-8;

location / {

# If the file exists as a static file serve it directly without
# running all the other rewite tests on it
if (-f $request_filename) {
expires max;

if ($request_filename !~ "\.(js|htc|ico|gif|jpg|png|css)$") {
rewrite ^(.*) /index.html last;

I'm obviously missing something, but how would one wrap this Map conditionally? If no "map" rules trigger, continue with "locations'...

Is this possible?

Thanks in advance!
Subject Author Posted


Goldcap October 15, 2009 05:34PM

Re: NginxHttpMapModule

Goldcap October 16, 2009 10:54AM

Re: NginxHttpMapModule

Igor Sysoev October 16, 2009 11:10AM

Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 88
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready