cancel
Showing results for 
Search instead for 
Did you mean: 

404 error for some internal sub-store pages in magento 2 with nginx

404 error for some internal sub-store pages in magento 2 with nginx

Hi folks, I am not able to access some internal pages of my store, however disabling the web/seo/use_rewrites it works perfectly.
 

I think it is some nginx configuration that is not right, I tried to create a rewriter, but there are many locations.

 

Here is my conf:

 

upstream fastcgi_backend {    server unix:/run/php-fpm/www.sock;
}
server {
    listen 80 reuseport default_server;
    server_name  _;
    root /var/www;
    index index.html index.php;
    location / {        try_files $uri $uri/ /index.php$is_args$args;
    }
    location ~ .php/ {          rewrite ^(.*.php)/ $1 last;
    }
    location ~ (index|get|static|errors/report|errors/404|errors/503|health_check)\.php {        fastcgi_pass    fastcgi_backend;        fastcgi_index  index.php;
        fastcgi_buffers 1024 4k;
        fastcgi_param  PHP_FLAG  "session.auto_start=off \n suhosin.session.cryptua=off";        fastcgi_param  PHP_VALUE "memory_limit=768M \n max_execution_time=18000";        fastcgi_read_timeout 600s;        fastcgi_connect_timeout 600s;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;        include fastcgi_params;        
    }
    error_log /var/log/nginx/debug.log debug;  
    access_log /var/log/nginx/debug.log;
}

 

if i managed to put a rewriter adding an index.php after each folder sub-store, i think the problem would be solved.

 

I tried to create a rule to always add index.php, however it downloads instead of being executed.

 

location / {    
try_files $uri $uri
/ /index.php$is_args$args @fallback; }
location @fallback {
rewrite
^/(\w*)/(.*)$ /$1/index.php/$2 last; }