How To Solve the "Redundant Hostname" Warning in Google Analytics

Last month (November 14th), Google introduced a change to their Analytics platform where users are now warned if "redundant hostnames" are linking to their website content. We have since been contacted by a number of clients that are concerned about this, and we therefore though it would be helpful to show you how you can easily solve this problem.

If you are an Analytics user you may see the following warning after logging in to your account:

"You have 1 unresolved issue: Redundant Hostnames"


What Google is trying to tell you is that more than one domain can be used to access a particular page. If multiple domains leads to the same page, Google and other search engines sees it as duplicate content and may hurt your rankings. By default, most web servers are configured to respond to both www.yourdomain.com and yourdomain.com, causing this issue if not additional steps are taken. This issue could also occur if your site is accessible by its IP address.

The solution is to ensure that all traffic goes to your site via your main domain. A simple way to do this is by adding a 301 redirect rule to your .htaccess file. Besides getting rid of the warning in your Analytics dashboard, it is good for SEO (search engine optimization) and recommended best-practice to ensure that all links to your site appears consistent across search engines. It is not important whether you choose the www or non-www version as your main domain as long as it is consistent.

To fix the problem, simply add the following to a .htaccess file at the root of your site:

RewriteEngine On # This line may already exist # Rewrite all requests to the 'www' version
RewriteCond %{HTTP_HOST} ^mydomain\.com$ [NC]
RewriteRule ^.*$ http://www.mydomain.com%{REQUEST_URI} [R=301,L]

If your site is also accessible by its IP address (usually only if you have a dedicated IP), use the following instead:

RewriteEngine On # This line may already exist # Rewrite all requests to the 'www' version
RewriteCond %{HTTP_HOST} ^mydomain\.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^123\.123\.123\.123$ [NC] RewriteRule ^.*$ http://www.mydomain.com%{REQUEST_URI} [R=301,L]

Remember to replace with your actual details (domain/IP) in the above rules. This small fix should keep Google happy and give you maximum in return for your SEO efforts! As an additional tip, if you are also using Google Webmaster Tools you should make sure to set your "Preferred Hostname" under Site Settings to ensure that your domain is consistent across all traffic from Google.