server { server_name somedomain.com; location /folder/ { return 301 $scheme://somedomain2.com; } } server { server_name somedomain2.com; location / { #index index.html; # You could wish to add that, if index default value does not suits your needs } }
That will issue a permanent redirect for any /folder/* request.
I took the liberty of mimicking the scheme being used with somedomain for somedomain2 with the $scheme
variable.
I have not forced the /index.html
URI in the redirect. You may wish to do it. I also relied on the default value of the index
directive, which is maybe not right for you.
If you wished to handle the content from the other server transparently, you could use proxy_pass
to proxy the request to it.