N
N
Nikita Reshetnyak2019-12-16 09:13:59
Nginx
Nikita Reshetnyak, 2019-12-16 09:13:59

How to redirect all requests to index.php NGINX?

Good day!
Redirection to index file does not work in NGINX. Maybe I'm doing something wrong...
The client part is working fine, that is, clicking on links like site/news/1 site/plugins/plugin is working fine. But if you try to do this in the admin panel, then 404
links like site/adm/plugins/plugin are thrown out giving 404
As far as I know, htaccess does not work in NGINX and you need to configure my config below, help me fix
it Configured NGINX From here https://serveradmin.ru /nastrojka-web-servera-nginx...
Thanks in advance!

server {
    listen 80;
    server_name internal.onclinic.local;
    root /web/sites/internal.onclinic.local/www/;
    index index.php index.html index.htm;
    access_log /web/sites/internal.onclinic.local/log/access.log main;
    error_log /web/sites/internal.onclinic.local/log/error.log;

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

    location ~* ^.+.(js|css|png|jpg|jpeg|gif|ico|woff)$ {
    access_log off;
    expires max;
    }

    location ~ \.php$ {
    try_files  $uri =404;
    fastcgi_pass   unix:/run/php-fpm/www.sock;
    fastcgi_index index.php;
    fastcgi_param DOCUMENT_ROOT /web/sites/internal.onclinic.local/www/;
    fastcgi_param SCRIPT_FILENAME /web/sites/internal.onclinic.local/www$fastcgi_script_name;
    fastcgi_param PATH_TRANSLATED /web/sites/internal.onclinic.local/www$fastcgi_script_name;
    include fastcgi_params;
    fastcgi_param QUERY_STRING $query_string;
    fastcgi_param REQUEST_METHOD $request_method;
    fastcgi_param CONTENT_TYPE $content_type;
    fastcgi_param CONTENT_LENGTH $content_length;
    fastcgi_param HTTPS on;
    fastcgi_intercept_errors on;
    fastcgi_ignore_client_abort off;
    fastcgi_connect_timeout 60;
    fastcgi_send_timeout 180;
    fastcgi_read_timeout 180;
    fastcgi_buffer_size 128k;
    fastcgi_buffers 4 256k;
    fastcgi_busy_buffers_size 256k;
    fastcgi_temp_file_write_size 256k;
    }

    location = /favicon.ico {
    log_not_found off;
    access_log off;
    }

    location = /robots.txt {
    allow all;
    log_not_found off;
    access_log off;
    }

    location ~ /\.ht {
    deny all;
    }
}


server {
     listen  80;
     server_name  www.internal.onclinic.local;
}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
dodo512, 2019-12-16
@trjflash

server {

    root /web/sites/internal.onclinic.local/www;
    index index.php index.html index.htm;

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

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

S
Sergey Eremin, 2019-12-16
@Sergei_Erjemin

this is how it works for me:

server {
    ...
    ...
    ...
    ...
    location / {
        root        /web/sites/internal.onclinic.local/www;
        try_files   $uri $uri/ /index.php;
        }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question