Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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_index   index.php;
    fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include         fastcgi_params;

The file structure is simple:


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:, server: , request: "GET /status/1.0/APP/ HTTP/1.1", upstream: "fastcgi://", host: ""

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

Thank you,

share|improve this question
I edited my question. – Thaxll Jan 17 '13 at 14:40
It looks more like a php issue (so fatscgi params). As the error comes bck from fastcgi, where php files are notfound. Check the php logs and give us your php pool settings. Especially the chroot settings if any. – regilero Jan 18 '13 at 8:37
I fixed the issue, it was a stupid error of location / and root parameter. – Thaxll Jan 18 '13 at 17:23
could you post your corrected configuration? – nysander Jan 23 '13 at 9:35
His root should be /var/www/html not /var/www/html/ because URIs start with a forward slash. – Dan Grossman Jan 28 '13 at 20:20

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.