rewrite issues

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


Hey,

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;
    server_name assets.mydomain.com;

    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 http://assets.mydomain.com/photos/1/106/small/photosmonalisa.jpg
it ends up looking for /photo/image/monalisa.jpg, which is incorrect.
If I hit http://assets.mydomain.com/photos/1/87/small/DSC02890.jpg 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
http://www.atmos.org/





More information about the nginx mailing list