lundi 16 avril 2018

Laravel 5 Nginx redirects to 404

My Laravel 5 website redirects to 404. It is installed in a folder.

It is using Laravel 5.6 and Nginx 1.12.1

It is redirecting to 404 instead of my project. Planning to deploy multiple sites.

https://example.com/staging/project/ -> Redirects to 404 instead of opening the page.

Find nginx config

server {
    listen       443 ssl http2 default_server;
    listen       [::]:443 ssl http2 default_server;
    server_name  _;
    root         /var/www/example;
    index   index.php index.html index.htm;

    ssl_certificate "/etc/letsencrypt/live/example.com/fullchain.pem";
    ssl_certificate_key "/etc/letsencrypt/live/example.com/privkey.pem";
    ssl_session_cache shared:SSL:1m;
    ssl_session_timeout  10m;
    ssl_ciphers HIGH:!aNULL:!MD5;
    ssl_prefer_server_ciphers on;

    # Load configuration files for the default server block.
    include /etc/nginx/default.d/*.conf;

    location / {
    }

    location ^~ /staging/project {
      alias /var/www/example/staging/project/public;
      index index.php
      try_files $uri $uri/ /index.php$is_args$args @laravel1;

    location ~ \.php {
       try_files $uri =404;
       fastcgi_pass 127.0.0.1:9000;
       fastcgi_param  SCRIPT_FILENAME $request_filename;
       fastcgi_param SCRIPT_NAME $fastcgi_script_name;
       fastcgi_split_path_info ^(.+\.php)(.*)$;
       fastcgi_index index.php;
       include /etc/nginx/fastcgi_params;
    }
  }

   location @laravel1 {
       rewrite /staging/project/(.*)$ /staging/project/index.php?/$1 last;
   }

    error_page 404 /404.html;
        location = /40x.html {
    }

    error_page 500 502 503 504 /50x.html;
        location = /50x.html {
    }
}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire