rewrite issues

Corey Donohoe atmos at
Wed Sep 19 12:03:13 MSD 2007


I have a weird problem with the way nginx is handling certain
rewrites.  I have a server definition that resembles the following.

  server {
    listen 80;

    root /data/mydomain/current/public/assets;

    location /photos {
      root /data/mydomain/current/public;
      rewrite ^/photos/(.*)$ /photo/image/$1 last;

    location /phobos {
      root /data/mydomain/current/public;
      rewrite ^/phobos/(.*)$ /photo/image/$1 last;

If I hit
it ends up looking for /photo/image/monalisa.jpg, which is incorrect.
If I hit it
works as expected.

The same urls with the /photos/ stuff replaced w/ /phobos/ works for
both images.

So I'm guessing the location /photos { } block is for some reason
matching the last part of the uri string instead of the entire string
as I requested.  Is this an error in my rewrite rule or an error in my
location block?

Any help is appreciated!

Corey Donohoe

More information about the nginx mailing list