Nginx-ru mailing list archive (nginx-ru@sysoev.ru)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: rewrite rul
On Wed, Jul 20, 2011 at 01:59:16PM -0400, yokodzun wrote:
> Пытаюсь сконвертить следующие rewrite
> правила из синтаксиса mod_rewrite в
> синтаксис Nginx:
>
> RewriteBase /
>
> RewriteCond %{REQUEST_FILENAME} !-f
> RewriteCond %{REQUEST_FILENAME} !-d
> RewriteCond %{REQUEST_FILENAME} !-l
> # Administration URL rewriting.
> RewriteRule ^admin(.*)$ admin/index.php?$1 [L,QSA]
>
> RewriteCond %{REQUEST_FILENAME} !-f
> RewriteCond %{REQUEST_FILENAME} !-d
> RewriteCond %{REQUEST_FILENAME} !-l
> # Main URL rewriting.
> RewriteRule ^(.*)$ index.php?PAGE=$1 [L,QSA]
>
> второе правило удалось застравить
> работать, первое - никак.
>
> конфиг такой:
>
> server {
> listen 80;
> server_name domain.tld
> location / {
> root /v/http/domain.tld;
> try_files $uri $uri/ @rewrite;
> autoindex off;
> }
>
> location @rewrite {
> rewrite ^/admin/(.*)$ /admin/index.php?$1;
> rewrite ^/(.*)$ /index.php?PAGE=$1;
> }
>
>
> location ~ \.php$ {
> fastcgi_pass unix:/tmp/php-fpm.sock;
> fastcgi_index index.php;
> fastcgi_param DOCUMENT_ROOT /v/http/domain.tld;
> fastcgi_param SCRIPT_FILENAME
> /v/http/domain.tld$fastcgi_script_name;
> include fastcgi_params;
> }
> }
>
> Где я ошибся? Почему для /admin/ не
> срабатывает правило?
Не надо rewrite. Тогда всё будет работать:
server {
listen 80;
server_name domain.tld
root /v/http/domain.tld;
location ~ \.php$ {
fastcgi_pass unix:/tmp/php-fpm.sock;
fastcgi_param DOCUMENT_ROOT /v/http/domain.tld;
fastcgi_param SCRIPT_FILENAME
/v/http/domain.tld$fastcgi_script_name;
include fastcgi_params;
}
location ~ ^/admin/(.*)$ {
try_files $uri $uri/ /admin/index.php?$1;
}
location ~ ^/(.*)$ {
try_files $uri $uri/ /index.php;
}
}
--
Игорь Сысоев
http://sysoev.ru
_______________________________________________
nginx-ru mailing list
nginx-ru@xxxxxxxxx
http://mailman.nginx.org/mailman/listinfo/nginx-ru
|