ПРОЕКТЫ 


  АРХИВ 


Apache-Talk @lexa.ru 

Inet-Admins @info.east.ru 

Filmscanners @halftone.co.uk 

Security-alerts @yandex-team.ru 

nginx-ru @sysoev.ru 


  СТАТЬИ 


  ПЕРСОНАЛЬНОЕ 


  ПРОГРАММЫ 



ПИШИТЕ
ПИСЬМА












     АРХИВ :: nginx-ru
Nginx-ru mailing list archive (nginx-ru@sysoev.ru)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Простой редирект с редствами nginx



Добрый день.

Что-то никак не могу заставить работать средствами nginx такой вот
простейший редирект:
RedirectMatch  301 ^/forums/$      /forums/index.php

Вроде бы такая конструкция должна прокатить:
location = /forums/     { redirect /forums/index.php; }
но nginx-овский redirect зачем-то прицепляет паттерн в конец URI,
и выходит вот что:
2005/02/02 12:06:23 [debug] 18419#0: *2 find location: = "/forums/"
2005/02/02 12:06:23 [debug] 18419#0: *2 http cl:-1 max:1048576
2005/02/02 12:06:23 [debug] 18419#0: *2 http redirect handler
.....
Location: http://127.0.0.1:8080/forums/index.phpforums/

Более того, в следующем цикле URL опять почему-то совпадает, хотя
по идее не должен, получается:
2005/02/02 12:13:15 [debug] 18535#0: *2 find location: "/"
2005/02/02 12:13:15 [debug] 18535#0: *2 find location: = "/forums/"
2005/02/02 12:13:15 [debug] 18535#0: *2 find location: ~ "^.+\.php$"
2005/02/02 12:13:15 [debug] 18535#0: *2 http cl:-1 max:1048576
--> 2005/02/02 12:13:15 [debug] 18535#0: *2 http redirect handler <-- ?????
.....
Location: http://127.0.0.1:8080/forums/index.phpforums/index.phpforums/

Почему вылезает отмеченная строчка, ведь location /forums/ не совпал?

Ну и на следующем этапе:
http://127.0.0.1:8080/forums/index.phpforums/index.phpforums/index.phpforums/
и т.п.

Что я делаю не так? Может, какое-то непонимание логики работы location
и редиректов?
Да, кстати, как бы еще добавить в redirect возможность указывать 301 :)


Мой конфиг:
worker_processes  1;

error_log  logs/error.log;
pid        logs/nginx.pid;

events {
    use rtsig;
    connections  1024;
}


http {
    include       conf/mime.types;
    default_type  application/octet-stream;

    server {
        listen  8080;
        access_log  off;
        rewrite_log on;

        location = /forums/     { redirect /forums/index.php; }

        location ~* ^.+\.php$ {
                fastcgi_pass  localhost:1234;
                fastcgi_root   /usr/local/nginx/html;
                fastcgi_index  index.php;

                fastcgi_connect_timeout       10;
                fastcgi_send_timeout          2m;
                fastcgi_read_timeout          3m;

                fastcgi_header_buffer_size    32k;
                fastcgi_buffers               4 32k;
                fastcgi_busy_buffers_size     32k;
                fastcgi_temp_file_write_size  64k;

                fastcgi_x_powered_by       off;
        }

        location / {
                root html;
                index index.htm index.html index.php;
        }
    }
}





 




Copyright © Lexa Software, 1996-2009.