rewrite

Igor Sysoev is at rambler-co.ru
Mon Oct 20 12:49:46 MSD 2008


On Mon, Oct 20, 2008 at 12:36:22PM +0400, alexey vilyansky wrote:

> Есть следующая конструкция в конфиге (nginx 0.7.19 FreeBSD 7.0-RELEASE)
> 
> location /images {
>    alias /home/vuser/src/storage;
>    if (!-f $request_filename) {
>      rewrite ^/images/(.*)/(.*)_(.*).jpg$ up_0_$3.jpg last;
>    }
> }
> 
> В nginx-error.log следующее:
> 
> 2008/10/20 11:05:15 [error] 96720#0: *469 open()
> "/usr/local/etc/nginx/htmlup_0_60.jpg" failed (2: No such file or
> directory), client: 89.175.80.253, server: vusersite.ru, request: "GET
> /images/15_10_2008/up_sdf_60.jpg HTTP/1.1", host: "vusersite.ru"
> 
> Почему картинка ищется там и как сделать чтобы искалась, где она на
> самом деле лежит?

Потому что if - плохая директива. Что видно в сочетании с alias.

Нужно что-то вроде:

 location /images {
    alias /home/vuser/src/storage;
    error_page  404  = @images;
 }

 location @images {
    root /home/vuser/src/storage;
    rewrite ^/images/(.*)/(.*)_(.*).jpg$ /up_0_$3.jpg break;
 }

Если файл - /home/vuser/src/storage/up_0_....jpg.


-- 
Игорь Сысоев
http://sysoev.ru





More information about the nginx-ru mailing list