I have a site example.com that runs wordpress. Now I want to move this blog to subdomain blog.example.com, but also I want following:
example.com --> static page (not wordpress)
blog.example.com --> new address to the blog
blog.example.com/foo --> handled by wordpress
example.com/foo --> permanent redirect to blog.example.com/foo
So I tried this next config:
server {
server_name example.com;
location = / {
root /home/path/to/site;
}
location / {
rewrite ^(.+) http://blog.example.com$request_uri? permanent;
}
}
In this case redirection is working perfectly. Unfortunately example.com redirects to blog.example.com too.