Welcome! Log In Create A New Profile

Advanced

rewrite и location (apach => nginx)

April 07, 2011 04:08AM
Помогите разобраться с конфигом nginx'a.
Пришлось отказаться от apache вообще и возникли некоторые трудности.

Вот файл .htaccess
RewriteEngine on
RewriteBase /scripts/
RewriteRule ^$ /scripts/
RewriteRule ^([a-z0-9_]+).php(.*)$ /scripts/$1.php$2


Вот что делал:
location / {
rewrite ^([a-z0-9_]+).php(.*)$ /scripts/$1.php$2 break;
}

При переходе на адрес sayt.ru/index.php редиректит на http://sayt.ru/home/sayt/www/scripts/home/sayt/www/scripts/home/sayt/www/scripts/

Еще было так
rewrite ^(.*)$ /scripts/$1 break;
В таком случае работал только index.php , а все ссылки на директории выше не работали (в которых расположены css , images etc), а другие скрипты из директории scripts выдавали "No input file specified."

Ну и последний способ был:
location ~* \.(php)$ {
alias /scripts/;
}

Задача банальная, перенаправлять все запросы с файлами php на директорию scripts. При этом пользователь видит в строке браузера http://sayt.ru/file.php, а не http://sayt.ru/scripts/file.php
Subject Author Posted

rewrite и location (apach => nginx)

cul8er April 07, 2011 04:08AM

Re: rewrite и location (apach => nginx)

cul8er April 09, 2011 04:22AM

Re: rewrite и location (apach => nginx)

Igor Sysoev April 09, 2011 04:44AM

Re: rewrite и location (apach => nginx)

cul8er April 09, 2011 06:00AM

Re: rewrite и location (apach => nginx)

Igor Sysoev April 09, 2011 07:18AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 289
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready