P
P
part_os2020-02-09 00:30:07
Nginx
part_os, 2020-02-09 00:30:07

Setting up nginx with a slash at the end, the site is no longer available, why?

Hello, I started setting up NGINX so that the site would be accessible with a slash at the end, it turned out that slashes https://photo-gileva-olga.ru/blog/ were added to all routes, but for some reason the root of the site is https://photo- gileva-olga.ru/ status 403 Forbidden is no longer available.

server {
    listen 80;
    listen 443 ssl;
    server_name photo-gileva-olga.ru;
    root /var/www/photo-gileva-olga/public;

    if ($request_uri ~ "^(.*)index\.(?:php|html)/(.*)") {
         return 301 $1$2;
    }
    if (!-f $request_filename) {
        rewrite [^/]$ $uri/ permanent;
    }

    if ($request_uri ~ ^(?P<left>[^?]*?)//+(?P<right>[^?]*)) {
        rewrite ^ $left/$right permanent;
    }

    location / {
       try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php$ {
        fastcgi_pass php:9000;
        fastcgi_split_path_info ^(.+\.php)(/.*)$;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        fastcgi_param DOCUMENT_ROOT $realpath_root;
        internal;
    }

    location ~ \.php$ {
        return 404;
    }

    error_log /var/log/nginx/photo-gileva-olga_error.log;
    access_log /var/log/nginx/photo-gileva-olga_access.log;
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dodo512, 2020-02-09
@part_os

Put away$uri/

location / {
    try_files $uri /index.php?$query_string;
}

Or add index
index index.php;

location / {
    try_files $uri $uri/ /index.php?$query_string;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question