Laravel API Route Get 404 On Nginx

- 1 answer

I have a Laravel project. It works on Mac os with nginx. I recentlly installed a CentOs 8. I installed Nginx on it and add the configuration bellow:

server {
    listen 8001;
    server_name _;
    root /usr/share/nginx/html/reservation_laravel/public;

    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-XSS-Protection "1; mode=block";
    add_header X-Content-Type-Options "nosniff";

    index index.html index.htm index.php;

    charset utf-8;

    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; }

    error_page 404 /index.php;

    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/run/php-fpm/www.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;

    location ~ /\.(?!well-known).* {
        deny all;

All routes inside web.php work fine but API routes not working! Same configuration is working on an Ubuntu server!



When you write on api.php add api on your url like


then you call it