Q: about "best" way for remove www in hostname in nginxish

Aleksandar Lazic al-nginx at none.at
Mon May 6 16:40:30 UTC 2013

Dear readers,

after reading


and googleing


I have a 'best solution' question.

I have the following customer request.

The 'normal User' type almost every time a www.subdomain.domain.at into 
they browser,
which does not exist but the subdomain.domain.at exists.

I would now add the follwing into my nginx.conf.

server {
server_name   ~^(www\.)?(?<domain>.+)$;

return http://$domain/;

Is this the cleanest way in nginxish?

Thanks for help

More information about the nginx mailing list