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 am trying to move my blog from blog.example.com to example.com/blog 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/blog.example.com/current/public/;
    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 example.com/blog nginx looks for:

/home/demo/public_html/blog.example.com/current/public/blog/index.php 

instead of

/home/demo/public_html/blog.example.com/current/public/index.php

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: http://wiki.nginx.org/NginxHttpCoreModule#alias

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

 
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.