Contents...
We know how to redirect old domain name to new domain name in Nginx, In this article I will explain how to permanently redirect non-www to www domain for example: looklinux.com to www.looklinux.com.
For good SEO purposes you can easily redirect non-www to www domain using following syntax.
Force Redirect Non-WWW To WWW Domain
Edit the nginx.conf file to force non-www to www domain.
# vim /etc/nginx/nginx.conf ### redirect non-www to www with client code 301 ### if ($host = 'looklinux.com' ) { rewrite ^/(.*)$ http://www.looklinux.com/$1 permanent; }
Save and close the file.
Reload Nginx
# service nginx relaod
Testing
Open your browser and type the below url:
http://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