September 27, 2019
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.
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.
Leave a reply