So, for instance, I have a domain olddomain.com
and newdomain.com
Here's how I want requests redirects to work:
sub.olddomain.com/hello/world -> sub.newdomain.com/hello/world
olddomain.com/hello/world -> newdomain.com/hello/world
There are many subdomains, so ideally I wouldn't want to create a rule for each one of them.
This seems like a solution:
server {
listen 80;
server_name olddomain.com *.olddomain.com;
rewrite ^(/)(.*)$ http://newdomain.com/$2 permanent;
}
but it doesn't work with subdomains, since all subdomains would redirect to newdomain.com/path
without regard for a subdomain.
Best Answer
You seem to be looking for something like this:
These are my testcases