Contents...
We now how redirect old domain name to new domain name in Nginx. In this article I will explain how to permanently redirect www to non-www domain for example: www.looklinux.com to looklinux.com.
For good SEO purposes you can easily redirect www to non-www domain using following syntax.
Force Redirect WWW To Non-WWW Domain
Edit the nginx.conf file to force www to non-www domain.
# vim /etc/nginx/nginx.conf ### redirect www to non-www with client code 301 ### if ($host = 'www.looklinux.com' ) { rewrite ^/(.*)$ http://looklinux.com/$1 permanent; }
Save and close the file.
Reload Nginx
# service nginx relaod
Testing
Open your browser and type the below url
http://www.looklinux.com/
It should be redirected to
http://www.looklinux.com/
Thanks:)
If you find this tutorial helpful please share with your friends to keep it alive. For more helpful topic browse my website www.looklinux.com. To become an author at LookLinux Submit Article. Stay connected to Facebook.
Leave a Comment