Как настроить .htaccess в nginx - PullRequest
0 голосов
/ 29 марта 2019

Я настраиваю новый vps-сервер, nginx, php-fpm (php 7.2). На старом сервере у меня в .htaccess

есть следующее
RewriteEngine on
RewriteBase /
RewriteRule index\.html$ index.php [NC]
RewriteRule Share-(.*)\.html$ index.php?a=Share&i=$1 [NC]
RewriteRule ^news-(.*)\.html$ index.php?a=news&i=$1 [L,NC]

nginx conf

server {
    listen   80;
    server_name  mysite.com;
    ssl_certificate /etc/nginx/ssl/nginx.crt;
    ssl_certificate_key /etc/nginx/ssl/nginx.key;
    # note that these lines are originally from the "location /" block
    root   /usr/share/nginx/html/mysite;
    index index.php index.html index.htm;

    location / {
        try_files $uri $uri/ =404;
    }
    error_page 404 /404.html;
    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
        root /usr/share/nginx/html/mysite/;
    }

    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
        fastcgi_read_timeout 300;

    }
}

Теперь это не работает в nginx. Как перевести этот .htaccess в nginx?

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...