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

Still pretty new to nginx here, trying to get a simple rewrite to work, but the server just responds '404 not found'

My server block

server {
listen   80;
listen   [::]:80;

root /home/pics;

rewrite ^(.*)$ index.php?tag=$1;

location / {

    try_files $uri $uri/ $uri.php /index.html $uri =404;
    #try_files $uri =404;

    fastcgi_split_path_info ^([a-z]+)(/.+)$;
    include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_pass unix:/tmp/php5-fpm.sock;
    fastcgi_index index.php;

location /doc/ {
    alias /usr/share/doc/;
    autoindex on;
    deny all;
} should rewrite to

share|improve this question
up vote 2 down vote accepted

Remove the rewrite and replace the try_files line with the following:

try_files $uri $uri/ /index.php?tag=$uri&$args;
share|improve this answer
Good stuff, thanks. This software is really cool! – Doug Oct 2 '12 at 17:57

Your Answer


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

Not the answer you're looking for? Browse other questions tagged or ask your own question.