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;
}
Written by Boris Quiroz
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Nginx
Authors
reiaguilera
279.4K
jamesdullaghan
90.14K
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#