Redirect everything except the homepage
- by Alex
Is there a way in nginx to redirect everything from domain1.com to domain2.com, except for the homepage?
Right now I have:
server {
listen 80;
server_name www.domain1.com domain1.com;
rewrite ^ http://domain2.com$uri permanent;
}
This works, except that I'd like http://domain1.com (without any additional path) to be left alone and not redirected. Basically, I need to redirect everything, to avoid broken links, but I want to use the homepage of domain1 to serve a static file.