Nginx Rewrite to Previous Directory
- by ThinkBohemian
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 \;
}