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?

2
  • 2
    Your server name is wrong Commented Jul 21, 2017 at 8:37
  • Possible duplicate of convert htaccess to nginx Commented Jul 21, 2017 at 8:51

1 Answer 1

0

Use

server_name test.local; 

instead

server_name productlocator.local; 

And then look this link

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.