rewrite

Igor Sysoev is at rambler-co.ru
Fri Aug 28 12:40:06 MSD 2009


On Fri, Aug 28, 2009 at 12:23:37PM +0400, Хордов Роман wrote:

> if ($request_filename !~ (js|gif|ico|jpg|jpeg|png|css|swf|html|xml|ppt|mov|txt)) {
>     rewrite ^(.*)$  /index.php;
>     }
> Т.е. все, кроме определенных форматов, перенаправлять на индекс.
> Все работает.
> Перенес nginx/0.6.36 на nginx/0.7.61 и rewrite перестал работать.
> 
> [notice] 17573#0: *1 "(js|ico|gif|jpg|jpeg|png|css|swf|html|xml|ppt|mov|txt)" does not match "/var/www/", client: 92.107.11.48, server: 71.151.120.10, request: "GET / HTTP/1.1", host: "71.151.120.10"
> 
> [notice] 17573#0: *1 "^(.*)$" matches "/", client: 92.107.11.48, server: 71.151.120.10, request: "GET / HTTP/1.1", host: "71.151.120.10"
> 
> Подскажите, пожалуйста, что не так делаю?

Не нужно использовать "if":

location / {
    fastcgi_pass ...
    fastcgi_param   SCRIPT_FILENAME  /path/to/index.php;
    ...
}

location ~ (js|gif|ico|jpg|jpeg|png|css|swf|html|xml|ppt|mov|txt) {
    root  /path/to/files;
}


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





More information about the nginx-ru mailing list