0

Previously I was working with Apache server (I had a special .htaccess) for my router, and everything worked as expected:

request: test.local/index/action was handled by test.local/index.php.

My .htaccess file was:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php

The problem: Now, I need to implement same functionality in Nginx. I implement nginx configs for my websites including in main nginx.conf -nginx folder- /include.d/test.conf . I tried this test.conf configuration:

server {
    listen       80;
    listen [::]:80;
    server_name  productlocator.local;
    root   /var/www/test/;
    index  index.php index.html;

    location ~ \.php$ {
         # fastcgi_split_path_info ^(.+?\.php)(/.*)$;
         try_files $uri $uri/ /index.php?$query_string;
         if (!-f $document_root$fastcgi_script_name) {
             return 404;
         }
         fastcgi_pass 127.0.0.1:9000;
         fastcgi_param SCRIPT_FILENAME $request_filename;
         include fastcgi_params;
     }
}

Requests to test.local/index.php are properly handled, but requests like test.local/index/action result with 404 Not Found error.

The question: How do I configure Nginx for my router to work?

tereško
  • 56,151
  • 24
  • 92
  • 147

1 Answers1

0

Use

server_name test.local;

instead

server_name  productlocator.local;

And then look this link

MikeSouto
  • 203
  • 1
  • 7