rewrite issues
Igor Sysoev
is at rambler-co.ru
Wed Sep 19 12:21:08 MSD 2007
On Wed, Sep 19, 2007 at 02:03:13AM -0600, Corey Donohoe wrote:
> 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;
You do not need "root" here, if you use rewrite only.
> 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?
If you have location given by regex, then requests may go there.
Try to disable regex search for this locations:
location ^~ /photos {
--
Igor Sysoev
http://sysoev.ru/en/
More information about the nginx
mailing list