How-to-solve-the-redundant-hostname-warning-in-google-analytics

Redundant hostname notifications come in Google Analytics when the Google result returns two or more variations of the website page the user searches. It happens when Google considers a single website as two different entities even if the content is same. For example, if the user searches for MyHostName.com, then Google will track and return www.MyHostName.com as well as MyHostName.com as two independent websites. This causes redundant-hostname-warning popping up on the screen. Hence the page gets split into two different websites. These kinds of errors are dealt by the offshore web hosting services before your website is hosted.

To avoid this kind of warning from Google, one can make a few changes in the website and then consider the right option to reach your website with the help of web hosting services India. The owner of the website should decide whether to choose to host the website with www or without. Once decided, then it is easier to avoid all the redundancies. Make sure what the right URL for the website is and then decide which one to choose for hosting your web page.

Follow these few steps to avoid the warning issued:

1) Apply a filter in Google Analytics

Most of the designers in web development in India work together to fix these redundancy issues by using simple to complicated coding analysis. Applying a filter to the Google analytics is the quickest way to fix the issue of the warning.

Applying filter is easier

Login to the user Google analytics user page then

Go to Admin>Filter >+ Add Filter>Consolidated Filter >Custom>Search and Replace

Converting WWW to non-www 

Filter Field: Hostname                                   google analytics

Search String: ^www\.

Replace String: leave it empty

Converting non-www to WWW

Filter Field: Hostname

Search String: ^MyHostName\.com$

Replace String: www.MyHostName.com

After this save the data and exit

2) Fixing with 301 directs

The modification is more technical; hence a thorough checkup is required before setting up the changes. If you are unsure about the changes then make sure that you are rightfully assisted by the web developer from Web Development Companies in India.  In this option, the websites with the apache server need to check the root directory where the hostnames are given in the Cpanel.  It may be a hidden file too, hence one needs to know the files existing in the system or seek the advice of an expert. Once the file is obtained, the following changes must be made:

To redirect from www to non-www RewriteEngine On RewriteCond %{HTTP_HOST} ^www.MyHostName.com [NC] RewriteRule ^(.*)$ http://MyHostName.com/$1 [L,R=301] To redirect a non www to www RewriteEngine On RewriteCond %{HTTP_HOST} ^MyExample.com [NC] RewriteRule ^(.*)$ http://www.MyExample.com/$1 [L,R=301]
If the website hostname is in Nginx then, after locating the configuration file, add these lines to it
www to non-www server { server_name www.MyHostName.com; rewrite ^/(.*)$ http://MyHostName.com/$1 permanent; }

Non-www to www

server {

server_name hostname.com;

rewrite ^/(.*)$ http://www.MyHostName.com/$1 permanent;

}

In case the website is made in the WordPress domain or PHP, then accessing the configuration files are tougher, hence adding these lines in the code would be sufficient.

Redirecting from www to non-www

<? php if ($_SERVER&#91;'HTTP_HOST'&#93; == 'www.MyHostName.com’) {

header ("Location: http://MyHostName.com".$_SERVER&#91;'REQUEST_URI'&#93;);

}

?>

Redirecting from non- www to www

<? php if ($_SERVER&#91;'HTTP_HOST'&#93;!= 'www.MyHostName.com'){

header ("Location: http://www.MyHostName.com".$_SERVER&#91;'REQUEST_URI'&#93;);

}

?>

3) After all the necessary modifications done, verify the changes made by checking your Google analytics again. Check the error message and verify by Checking again. Once the changes get reflected, the error message will show resolved status, thereby removing the redundancy from your web pages.