remove www from the url

Francis Daly francis at daoine.org
Thu Feb 17 18:51:33 MSK 2011


On Thu, Feb 17, 2011 at 09:44:10AM -0500, whiskybar wrote:

Hi there,

By now you've seen the "approved" way to do what you want.

But it looks to me as if the behaviour you see is to be expected, based
on the documentation you quote:

> "Note that if a redirect is relative (has no host part), then
> when redirecting Nginx uses the "Host" header if the header match name
> of server_name directive

Host header is www.mysite.com. server_name includes www.mysite.com. So you
rewrite http://www.mysite.com/abc to http://www.mysite.com/abc. It's quite
reasonable for a browser to report that this isn't a useful redirect,
exactly as Firefox does.

Other than a little bit of grammar, the documentation looks correct.

> Well, this method no longer works. I do not know when it stopped working

Most likely it was in 0.8.48, where the default value for
server_name_in_redirect was set to "off".

That suggests that you could, if you wanted to avoid the
"proper" way, keep your current configuration and add an explicit
"server_name_in_redirect on".

If you included mention of the previous and current versions used,
it might show that that analysis is incorrect.

All the best,

	f
-- 
Francis Daly        francis at daoine.org



More information about the nginx mailing list