我想重定向请求到我的服务器上的/images/someimage.png到http://some.other.server/images/someimage.png。我在我的nginx的配置如下:Nginx的位置重定向正则表达式不起作用
location ^/images/.*(png|jpg|gif)$ {
rewrite ^/images/(.*)(png|jpg|gif)$ http://anotherserver.com/images/$1$2 redirect;
return 302;
}
但出于某种原因没有得到命中,当我要求http://test.com/images/test.png(我只是得到一个404,因为该文件不上MYSERVER存在)。
添加〜做了窍门。我只想重定向,如果它是该目录中的图像文件。 – user1781088