Issue with auto subdomain nd trailing slash

shumisha nginx-forum at
Fri Feb 22 13:39:46 UTC 2013

Hi Francis,

Thanks a lot for your message, I think I got things under control thanks to

You're right, there's indeed a 301 thrown by nginx from to
(as shown by the curl output).

I had tried server_name_in_redirect to off before, to no avail, but I tried
again, just in case. I looked up the documentation again, and I realized:

- it's probably not active on my version, as nginx still uses the first
server in the server_name directive regardless of the directive value.
However, it's a valid config value
- but that got me thinking and I simply switched the orders of server, so
that it reads:

server_name *;

So now the automatic redirect still happens (I think it should be
configurabe, maybe it is) but by placing the * server first in the
server_name directive, the sub domain is preserved and the redirect now
happens with the correct host.

Thanks again for your help :)


Posted at Nginx Forum:,236469,236477#msg-236477

More information about the nginx mailing list