Geeks Geeks - 4 months ago 26
PHP Question

Nginx Laravel Route as Codeigniter

I have a Laravel 5 project, the staffs information can be access from testing.com/staffs, but I want to change the URL to testing.com/test/index.php/staffs, I have tried the Laravel Route group using "test/index.php/", but laravel did not support "dot" in route, How can I do that?

the following is my part of nginx.conf

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

location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|css|js)$ {
expires max;
}

location ~ [^/]\.php(/|$) {
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
if (!-f $document_root$fastcgi_script_name) {
return 404;
}

fastcgi_pass 127.0.0.1:9006;
fastcgi_index index.php;
include /etc/nginx/fastcgi_params;
}
}

Answer

I think Rickard Smith might Right!! the following are the finally code

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

location ~ \.php$ {
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass    127.0.0.1:9006;
    fastcgi_index index.php;
    include /etc/nginx/fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

    fastcgi_intercept_errors off;
    fastcgi_buffer_size 16k;
    fastcgi_buffers 4 16k;
    fastcgi_connect_timeout 300;
    fastcgi_send_timeout 300;
    fastcgi_read_timeout 300;
}

Then you can use Route Group Prefix with "dot" now, Thanks Rickard Smith and shempignon Help!!