Hi, I have a site which hosts several domains and they are all
redirected to a single vhost. I then want to redirect “/” to some
starting URL, but when I do so the hostname in the URL changes to the
first server name in my config, rather than staying the same as the user
requested
eg, user goes to “http://webmail.theirsite.com/” and it should redirect
to “http://webmail.theirsite.com/src/login.php”, but what actually
happens is that it goes to http://webmail.genericsite.com/src/login.php
Config:
server {
server_name webmail.genericsite.com webmail.theirsite.com
rewrite ^/$ /src/login.php redirect;
etc
}
Suggestions please on how to fix this? (Use an IF perhaps? Seems
ugly?)
Ed W
On Wed, May 14, 2008 at 04:36:43PM +0100, Ed W wrote:
Config:
server {
server_name webmail.genericsite.com webmail.theirsite.com
rewrite ^/$ /src/login.php redirect;
etc
}
Suggestions please on how to fix this? (Use an IF perhaps? Seems ugly?)
What nginx version do you use ? If 0.6.x, then you should use
server {
server_name_in_redirect off;
BTW, it’s better to use:
location = / {
rewrite ^ /src/login.php redirect;
}
instead of
rewrite ^/$ /src/login.php redirect;
on server level.
Could it be
“server_name_in_redirect off;”
?
On 5/14/08, Igor S. [email protected] wrote:
server {
server_name_in_redirect off;
I was thinking this was the right parameter - but it doesn’t look like
it’s on the wiki at all. It should be listed on the
NginxHttpCoreModule page, correct?
If you have a sentence or two writeup, I’ll update the wiki
On Wed, May 14, 2008 at 11:41:59AM -0700, mike wrote:
On 5/14/08, Igor S. [email protected] wrote:
server {
server_name_in_redirect off;
I was thinking this was the right parameter - but it doesn’t look like
it’s on the wiki at all. It should be listed on the
NginxHttpCoreModule page, correct?
Yes.
If you have a sentence or two writeup, I’ll update the wiki
If server_name_in_redirect is on, then nginx will use the first name
of server_name directive in redirects. If server_name_in_redirect is
off,
then nginx will use a request Host header.
server_name_in_redirect can be set on http, server, and location level.
excellent. thanks. if anyone else has anything to add/fix on it, go for
it 
http://wiki.codemongers.com/NginxHttpCoreModule#server_name_in_redirect