Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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,

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

 
discard

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

Browse other questions tagged or ask your own question.