redirect based on hostname
sevy
nginx-forum at nginx.us
Wed Mar 23 15:40:36 MSK 2011
I've read the whole NginX wiki and couldn't find a solution yet. So
would you be so gentle to tell me how to do this.
I have two (2) domains on the same website. Let's say "www.first.com"
and "www.second.com"
The frontend php shares the same files and the only difference is in the
layout so I must differentiate the layout based on the hostname header
sent by client.
My goal would be to redirect to the www domain if an invalid subdomain
is typed.
example: error.first.com must redirect to www.first.com as well as
wrong.second.com must redirect to www.second.com
My setup when I was using a single domain was easy:
if ($host !~* "www.first.com") {
rewrite ^(.*)$ http://www.first.com$1 permanent;
break;
}
but now my need is to do something like:
if ($host !~* "www.first.com|www.second.com") {
rewrite ^(.*)$ (what to put here???)$1 permanent;
break;
}
Thanks to anyone able to help me out with this issue...
Posted at Nginx Forum: http://forum.nginx.org/read.php?2,185113,185113#msg-185113
More information about the nginx
mailing list