I want to redirect requests to /images/someimage.png on my server to http://some.other.server/images/someimage.png. I have the following in my nginx config:
location ^/images/.*(png|jpg|gif)$ { rewrite ^/images/(.*)(png|jpg|gif)$ http://anotherserver.com/images/$1$2 redirect; return 302; } But for some reason it isn't getting hit when I request http://test.com/images/test.png (I just get a 404 because that file doesn't exist on myserver).