Smack Digital Inc.

SEO Www Or Not To Www - Pick A Preference!

Posted by and last updated Jun 22, 2014 02:27 AM

SEO tutorial providing instruction on how to pick a www or non-www preference and configure X-Cart accordingly.

I'm frequently asked whether or not one should use www. (i.e. http://www.example.com/) or (i.e. http://example.com) when optimizing for search engines. It's not going to impact your SEO rankings one way or the other, but search engines will see the url with and without www as two distinct urls, so you should always pick a preference. While "w-w-w" was the buzz word of the 'old' days, it's now an accepted and redundant part of the web, so it would make sense to drop the www; call me a traditionalist though, I just can't do it.

Here's how you configure your X-Cart to force a single format.

Set X-Cart Domain Preference

Open your config.php file and look for the $xcart_http_host and $xcart_https_host variables and ensure the domains are input with your desired prefix:


$xcart_http_host = 'www.example.com'
$xcart_https_host = 'www.example.com'


$xcart_http_host = 'example.com'
$xcart_https_host = 'example.com'

Tell Google

In google webmaster central settings - if you don't have an account its an SEO must to register one - you can set a preferred domain:

The preferred domain is the one that you would like used to index your site's pages. If you specify your preferred domain as http://www.example.com and we find a link to your site that is formatted as http://example.com , we'll treat that link as if it was http://www.example.com . In addition, we'll take your preference into account when displaying URLs in our search results. It may take some time for changes to be reflected in our index.

Preferred domain

Force Domain Preference

In your .htaccess, you can then force to use or not use the www. using the appropriate block of code below. Any www or non-www url usage will be automatically redirected to the desired type.


# WCM - Force www.
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
# / WCM - Force www.


# WCM - Force non-www.
RewriteCond %{HTTP_HOST} ^www\.example\.com [NC]
RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]
# / WCM - Force non-www.

About the Author

Jonathan Peters Jonathan's founder of Smack Digital, a digital strategy agency that creates and executes online business success for executives who are highly motivated to quickly increase their market share. With more than two decades of experience on the web for clients ranging from non-profits to billion dollar enterprises, Jonathan's an expert in web development, eCommerce, software programming, search engine optimization and social media marketing.
We choose our clients selectively.
Let's talk success. Apply to work with us.
Apply toWork With Us
Apply toWork With Us