X-Cart Search Engine Optimization Blog

X-Cart SEO blog with articles and tips to assist you in optimizing x-cart for improved search engine rankings.

Search


Keep in the know! Subscribe to our eZine at the top right and have these seo tips delivered directly to your email box monthly, or subscribe to our:

X-Cart SEO RSS Feed

SEO WWW or Not to WWW - Pick a Preference!

Posted by Jon Peters on January 6, 2009

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:

www.

$xcart_http_host ="www.example.com";
$xcart_https_host ="www.example.com";

non-www.

$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 approriate block of code below. Any www or non-www url usage will be automatically redirected to the desired type.

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

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