Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I am trying to move my blog from to to do this I would rather not move anything on disk, so instead i changed my nginx configuration file to the following:

location /blog {
if (!-e $request_filename) {
    rewrite ^.*$ /index.php last;
    root /home/demo/public_html/;
    index  index.php index.html index.html;
        passenger_enabled off;
        index index.html index.htm index.php;
        try_files $uri $uri/ @blog;

This works great but when i visit nginx looks for:


instead of


Is there a way to put in a rewrite rule so that I can have the server automatically take out the /blog/ directory?

something like ?

location /blog {
        rewrite \\blog\D  \;
share|improve this question

1 Answer 1

up vote 1 down vote accepted

You have misunderstood the usage of root. What you really want is the alias directive:

share|improve this answer
thanks so much for answering, i was beginning to get a little lonely here ^_^ –  Schneems May 4 '10 at 20:44
When I change root to alias i get error "No input file specified." when i visit the page and no errors in my error.log –  Schneems May 5 '10 at 15:15
This has to do with your SCRIPT_FILENAME fastcgi param value. –  Martin Fjordvald May 5 '10 at 22:46
I ended up being able to use a symlink to the correct directory. –  Schneems May 6 '10 at 20:43

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.