June 16, 2020
1min Read
Merkys M.
Redirecting non-www requests to the www version of your website’s URL is beneficial for SEO purposes. Not only will it help you to avoid duplicate content on the Google index, but it will also avoid the possibility of split page rank and or split inbound links. In this article, we will learn how to redirect non-www to www URLs using the .htaccess file in your public_html folder.
Upgrade your Hosting and get up to 90% OFF Web Hosting Plans with Hostinger + Free SSL certificate!
To redirect a non-www URL to www, we need to place a rule in the .htaccess file. You can do it via FTP, SSH, or your control panel.
Follow the steps below to edit your .htaccess file from Hostinger’s hPanel:
RewriteEngine On RewriteCond %{HTTP_HOST} ^yourdomain.com [NC] RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [L,R=301]
Congratulations, you have successfully enabled a .htaccess rule that will redirect all visitors from a non-www URL to the www version of your website! Wasn’t hard at all, was it?
There you have it! By finishing this tutorial, you have learned how to redirect non-www URLs to www. From now on, when someone accesses http://yourdomain.com, they will be redirected to http://www.yourdomain.com.
Hopefully, this tutorial was helpful. Let us know in the comments below if you face any issues.
February 12 2020
Thanks!!
August 02 2020
Thanks for the insight! Looking to do exactly this. I need to get my cdn working, and www is necessary for that. One question I have is in addition to www, I need it to go to https. Would I just add the https in place of the http?
Leave a reply