Laravel 5.4 new project nginx redirecting to 404 on every route except index

December 11, 2017 697 views
Nginx

I'm setting up new Laravel 5.4 project on a Ubuntu 16.04.3 x64 nginx machine. The index page works fine but when i try using any other route it takes me to a 404 page. In my development environment, the routes are working fine. I'm guessing it has to do with my server setup.

Below is my information for the server:

server {
        listen 80;
        listen [::]:80;

        root /var/www/dev.drmanansala.com/public;

        index index.php index;

        server_name dev.drmanansala.com;

        error_page 404 /404page.php;

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

        location ~ \.php$ {
                include snippets/fastcgi-php.conf;
                fastcgi_pass unix:/run/php/php7.0-fpm.sock;
        }

        location ~ /\.ht {
                deny all;
        }

    listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/dev.drmanansala.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/dev.drmanansala.com/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

    if ($scheme != "https") {
        return 301 https://$host$request_uri;
    } # managed by Certbot
}
Be the first one to answer this question.