Rewrite all requests for non existing files to index.php with try_files with Nginx

Viewed 831

I am trying to convert trivial htaccess file to Nginx and can't make it work. It returns 404 error. Here is htaccess content:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [L]

Here is my current nginx config:

server {
listen 80;
server_name domain.biz;
root /var/www/domain.biz;
charset utf-8;
autoindex off;

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

location ~ \.php$ {
include        fastcgi_params;
fastcgi_pass   unix:/var/run/php5-fpm.sock;
fastcgi_param SCRIPT_FILENAME /var/www/domain.biz$fastcgi_script_name;
}
}
1 Answers
Related