For WordPress
First of all, let's answer the question whether a site with www or without www is better, the answer is simple, everything is a matter of choice and there is no better or worse, it is a matter of choice. But if you start using one, don't mix it up, i.e. links to www and others without www.
In order to prevent such errors, since Google sees the same site as two separate ones if you use both www and no www. You can create a redirection so that when someone types www.vassajt.com they are redirected to https://vassajt.com
This is achieved with a simple redirection in the htaccess file.
If you use cPanel, log in and find File Manager
Then, in the public_html folder, find the .htaccess file (with all dots). If you don't see it, then click the upper right corner "Settings" and tick Show Hidden files and folders. .htaccess file will appear.
If you use wordpress, your htaccess file should look like this:
# BEGIN WordPress
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress
Under "RewriteEngine On" add the following:
RewriteCond %{HTTP_HOST} ^www\.vassajt\.com [NC]
RewriteRule ^(.*)$ http://vassajt.com/$1 [L,R=301]
And finally the whole htaccess file should look like this:
# BEGIN WordPress
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.vassajt\.com [NC]
RewriteRule ^(.*)$ http://vassajt.com/$1 [L,R=301]
RewriteBase /
RewriteRule ^index\.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress
For other sites
Save this to your .htaccess file:
RewriteEngine On RewriteCond %{HTTP_HOST} !^www\. [NC] RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
