7 messages in ru.sysoev.nginxRe: HTTP directory redirect not using...
FromSent OnAttachments
Bob IppolitoSep 19, 2006 3:31 pm 
Igor SysoevSep 19, 2006 4:03 pm 
Bob IppolitoSep 19, 2006 4:09 pm 
Cliff WellsSep 20, 2006 11:19 am 
Igor SysoevSep 20, 2006 11:58 pm 
Cliff WellsSep 21, 2006 12:43 am 
Igor SysoevSep 21, 2006 8:43 am 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: HTTP directory redirect not using $hostActions...
From:Igor Sysoev (is-G@public.gmane.org)
Date:Sep 21, 2006 8:43:20 am
List:ru.sysoev.nginx

On Tue, 19 Sep 2006, Bob Ippolito wrote:

On 9/19/06, Igor Sysoev <is-G@public.gmane.org> wrote:

On Tue, 19 Sep 2006, Bob Ippolito wrote:

It seems that the redirection from http://example.com/somedir to http://example.com/somedir/ does a 302 using the local hostname rather than the Host header.

I was able to work around the issue using rewrite: if (-d $request_filename) { rewrite ^(.*[^/])$ http://$host$1/; }

It would be nice if this was fixed in a future release. I looked around in the source for a bit, but I wasn't able to find exactly what needs to be changed.

Had you set "server_name" ?

server { server_name example.com www.example.com; ... }

server { server_name example1.com www.example1.com; ... }

nginx uses first name of the "server_name" directive in redirect. If server_name is not set, then it uses local hostname.

In this case, I did not set any server_name. Why not use the Host header always, and default to server_name only if the client didn't send one? You should really have to explicitly redirect to a different host, the implicit redirections should simply work with the Host they were given by the client.

I was wrong, I've just changed wiki:

The basic name of server is used in an HTTP redirects, if no a "Host" header was in client request or that header does not match any assigned server_name.