There is no matter if you use www or non-www site. Search engine doesn’t stop you to use one of them. But if you’re using a non-www and want to redirect all your site into www version or www to non-www with htaccess then here is the solution for you.
In all website root directory, there will be a .htaccess file exists. So you can easily redirect all of the requests for yourdomain.com domains to www.yourdomains.com by modifying it.
Many people trying to find the solution to force either the www or non-www of their sites. Now follow below guides to learn how to force non-www to www in .htaccess OR www to non-www in your webhosting Cpanel account.
How to Redirect Non-WWW to WWW in .htaccess File
(NOTE: I’ll Use iPage WebHosting CPanel)
Step1. Log In to your webhosting CPanel account and go to “File Manager”.
Step2. Click on the Settings at the top right corner.
Step3. Make sure you’ve checked the System Files and other options like hidden files etc.
Step4. Now open the root directory folder where you install your site and find the .httaccess file. Go to its menu and click on Edit option.
Step5. Now you’re comes in text editor. Simply copy the below code to force non-www to www version. Be sure that to replace ‘yourdomain.com’ with your actual domain name.
How to Force WWW to Non-WWW in .htaccess File in CPanel
Above, I’ll show you how to redirect your non-www website address to www version using .htaccess file into your webhosting CPanel. Now here I’ll show you how to force www to non-www in .htaccess file.
Follow all the above steps, just copy the below piece of code and replace instead of upper one.
Now, when you type in your domain name with either www in front or not, it should display as you have set it in the .htaccess file. I hope you may be easily understand this amazing SEO trick that helps you to easily force and redirect your website site address in www or non-www version. If you face any problem comment below and I’ll resolved it as soon as possible.