我想重定向請求到我的服務器上的/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