Nginx Rewrite to subdirectory

Check out at: https://serverfault.com/questions/335126/nginx-rewrite-from-base-domain-to-a-sub-directory

location = / {
    rewrite ^ http://site.com/blog/ redirect;
}

This’ll just do requests specifically for the root. If you need to catch everything (redirect http://site.com/somearticle/something.html to http://site.com/blog/somearticle/something.html ), then you’ll need something more involved:


location / {
    rewrite ^/(.*)$ http://site.com/blog/$1 redirect;
}