One important aspect of SEO basics is that we use “WWW Resolve” on our domain name. While we know that domain.com and www.domain.com may be pointing to the same website, search engines don’t know that and they will treat them as two duplicate websites and that’s going to hurt your page ranking. So it’s important to redirect all requests from a non-preferred domain into one URL.
The first step to do it is to setup our .htaccess
file under our website directory. Open the file and put this on the very top. If you use WordPress, make sure you put these codes outside any WordPress custom codes.
RewriteEngine On RewriteCond %{HTTP_HOST} ^itnota.com$ RewriteRule ^/?$ "https://www.itnota.com/" [R=301,L] RewriteCond %{HTTP_HOST} ^itnota.com$ [NC] RewriteRule ^(.*)$ https://www.itnota.com/$1 [R=301,L]
Once the file is saved, you can test it by typing your domain.com (without the ‘www’) in your browser, the ‘www’ should be added automatically.
As the next step, you can also set how search engines would display your domain URL on their search result. For Google, you can use your Google account and sign up to Webmaster Tools and in Configuration – Settings you can set your Preferred domain.
With these two settings, you can be rest assured that Google will know how to display your URL correctly in its search result, and other http requests that don’t include ‘www’ in your domain will be corrected with the .htaccess
settings.
Leave a Reply