NGINX: Routes ending in .php

Posted 3 years ago by ShaneTurner

This is likely an Nginx config issue, but so far I haven't found a solution.

I have a standard 404 page for non existent file requests, and this works file. Except for files ending .php, the server just returns a default "File not found." It's clearly not being processed by Laravel.

eg: website.com/somefile.php

Anyone know the correct config to get this working?

Current config:

server {
    listen 443 ssl;
    server_name website.dev www.website.dev;
    root /home/development/code/sites/website.dev/public;

    index index.html index.htm index.php;

    charset utf-8;

    ssl_certificate /home/development/.ssl/nginx.crt;
    ssl_certificate_key /home/development/.ssl/nginx.key;


    rewrite ^/(.*)/$ /$1 permanent;

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

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

    access_log off;
    error_log /home/development/code/log/website.dev.error.log error;

    sendfile off;

    client_max_body_size 100m;

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_intercept_errors off;
        fastcgi_buffer_size 16k;
        fastcgi_buffers 4 16k;
    }

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

Please sign in or create an account to participate in this conversation.