Nginx rewrite

elitedesign
На сайте с 25.10.2012
Offline
69
361

Всем привет. Перехожу на Nginx и сталкиваюсь с тем, что пока не до конца врубаюсь как там редиректы настраивать.

Что мне нужно:

При открытии: http://domain.com/news

Чтобы открывалось бы на самом деле: http://domain.com/index.php?page=news

В ISPManager у меня вот такой конфиг. Он меня пугает огромедностью. Почти все в нем понимаю, кроме того, куда вписать требуемую строчку чтобы заработало то что мне нужно.

server {
server_name domain.com www.domain.com;
charset UTF-8;
index index.php index.html;
disable_symlinks if_not_owner from=$root_path;
include /etc/nginx/vhosts-includes/*.conf;
include /etc/nginx/vhosts-resources/domain.com/*.conf;
access_log /var/www/httpd-logs/domain.com.access.log;
error_log /var/www/httpd-logs/domain.com.error.log notice;
set $root_path /var/www/domain.com/data/www/domain.com;
root $root_path;
listen 217.23.1.57:80;
location / {
location ~ [^/]\.ph(p\d*|tml)$ {
try_files /does_not_exists @php;
}
}
location @php {
fastcgi_index index.php;
fastcgi_param PHP_ADMIN_VALUE "sendmail_path = /usr/sbin/sendmail -t -i -f info@domain.com";
fastcgi_pass unix:/var/www/php-fpm/domain.com.sock;
fastcgi_split_path_info ^((?U).+\.ph(?:p\d*|tml))(/?.+)$;
try_files $uri =404;
include fastcgi_params;
}
return 301 https://$host:443$request_uri;
}
server {
server_name domain.com www.domain.com;
ssl on;
ssl_certificate "/var/www/httpd-cert/domain.com/domain.com.crtca";
ssl_certificate_key "/var/www/httpd-cert/domain.com/domain.com.key";
ssl_ciphers EECDH:+AES256:-3DES:RSA+AES:!NULL:!RC4;
ssl_prefer_server_ciphers on;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
add_header Strict-Transport-Security "max-age=31536000;";
ssl_dhparam /etc/ssl/certs/dhparam4096.pem;
charset UTF-8;
index index.php index.html;
disable_symlinks if_not_owner from=$root_path;
include /etc/nginx/vhosts-includes/*.conf;
include /etc/nginx/vhosts-resources/domain.com/*.conf;
access_log /var/www/httpd-logs/domain.com.access.log;
error_log /var/www/httpd-logs/domain.com.error.log notice;
set $root_path /var/www/domain.com/data/www/domain.com;
root $root_path;
listen 217.23.1.57:443;
location / {
location ~ [^/]\.ph(p\d*|tml)$ {
try_files /does_not_exists @php;
}
}
location @php {
fastcgi_index index.php;
fastcgi_param PHP_ADMIN_VALUE "sendmail_path = /usr/sbin/sendmail -t -i -f info@domain.com";
fastcgi_pass unix:/var/www/php-fpm/domain.com.sock;
fastcgi_split_path_info ^((?U).+\.ph(?:p\d*|tml))(/?.+)$;
try_files $uri =404;
include fastcgi_params;
}
}

Понимаю что мне нужно в location вставить вот такую строчку:

rewrite ^/(.*)$ /index.php?page=$1 last;

Вставляю, но почему то все равно не работает.

Подскажите плиз, как решить данный вопрос. Где я затупил?

neoks
На сайте с 17.03.2010
Offline
152
#1

Что то вроде такого в верх "location / {"

try_files $uri $uri/ /index.php?$args;

elitedesign
На сайте с 25.10.2012
Offline
69
#2
neoks:
Что то вроде такого в верх "location / {"
try_files $uri $uri/ /index.php?$args;

Спасибо! Помогло сразу!

Авторизуйтесь или зарегистрируйтесь, чтобы оставить комментарий