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.

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;

server_name pics.example.com;
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;
    allow 127.0.0.1;
    deny all;
}
}

pics.example.com/foobear should rewrite to pics.example.com/index.php?tag=foobear

share|improve this question
add comment

1 Answer 1

up vote 1 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
add comment

Your Answer

 
discard

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.