For SEO reasons, it's best to redirect your non-www site URL to www or vice version.
Technically, the non-www version and the www version are two different domains. So redirecting one to the other improves our SEO. Google and other search engines won't have to worry about two different domains.
This tutorial will show you how to redirect your whole Joomla site (running on Apache) to either non-www or www.
You will need t your .htaccess file and find the line that reads:
RewriteEngine On
To redirect non-www to www, add this code below it:
RewriteCond %{HTTP_HOST} ^yourdomain.com [NC]
RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [L,R=301]
To redirect www to non-www, add this code after RewriteEngine On:
RewriteCond %{HTTP_HOST} ^www.yourdomain.com [NC]
RewriteRule ^(.*)$ http://yourdomain.com/$1 [L,R=301]