2

I'm trying to convert a very simple .htaccess file to nginx:

Options -Indexes -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

As I read on Google and many places, try_files should do the trick. I tried many things but it just doesn't work, looks like nothing is sent to index.php

server {

root   /var/www/html/;

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

location ~ \.php$ {
    fastcgi_pass    127.0.0.1:9000;
    fastcgi_index   index.php;
    fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include         fastcgi_params;
    }
}

The file structure is simple:

/var/www/html/folder1/folder2/index.php
/var/www/html/folder1/folder2/.htaccess

Nginx error log when requesting the url:

013/01/17 14:38:28 [error] 22379#0: *1 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 1.2.3.4, server: , request: "GET /status/1.0/APP/ HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "test.com:443"

I'm not sure if the problem is a try_files issue or fastcgi_path.

Thank you,

Thaxll
  • 21
  • 3

0 Answers0