Last Updated: February 25, 2016
·
471
· boris

Nginx redirect www to non-www

I don't like the "www." part on URLs. I try to avoid them (I know it's useful, but I don't like it) and I always try to redirect to non-www.

Using Apache is quite simple, and so it's on Nginx! Just add the following code to your configuration:
server { server_name www.mydomain.com; rewrite ^(.*) http://mydomain.com permanent; }