Author Topic: Redundant Hostnames error  (Read 291 times)

adlluvia2017

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • Adlluvia Classifieds
Redundant Hostnames error
« on: December 29, 2017, 05:41:58 AM »
A few days ago I received a notification in my google analytics account that :-
 " Redundant Hostnames error
Property http://adlluvia.com is receiving data from redundant hostnames."
Plz help anyone to solve this problem and also what does it mean "Redundant Hostnames error"

Thanks
www.adlluvia.com



Mike

  • Newbie
  • *
  • Posts: 15
    • View Profile
Re: Redundant Hostnames error
« Reply #1 on: January 01, 2018, 01:38:20 AM »
you are receiving the redundant hostname notification it means that Google Analytics is tracking your domain www.example.com and example.com independently. This means that your pages will be split across two URLs even if they provide the same content.

For example, considering the URL of this post, Google Analytics would be tracking these 2 as a different page.
www.example.co/redundant-hostnames-google-analytics
example.co/redundant-hostnames-google-analytics
You can prevent this by consolidating both domains into one.

Before proceeding, you have to decide if you preferred to show your domain with or without WWW. There are a few technical differences but in general, it is only a matter of personal preference.



Step 1: Quick Fix for Redundant Hostnames With a Filter in Google Analytics

Redundant Hostnames in Google Analytics
To fix the notification "redundant hostnames" in Google Analytics:

a) Go to the admin section.
b) Click on Filters on the 3rd column VIEW, then click the red button +Add Filter.
c) Enter "Consolidate hostnames" as name and select Custom for filter type
d) From the radio button list select Search and replace (you might need to scroll a little).how-to-fix-the-redundant-hostname-error-in-google-analytics
e) Configure the filter depending on how you want your hostname to appear.
Converting WWW to non-www
Filter Field: Hostname
Search String: ^www\.
Replace String: leave it empty
Converting non-www to WWW
Filter Field: Hostname
Search String: ^yourdomain\.com$
Replace String: www.yourdomain.com

 f) Save your filter and continue to the next part (You can click verify this filter before saving to have a quick glance of how it will work)
This will solve the redundant hostname in Google Analytics, however, your site will still have 2 separate URLs for each page, so I recommend you to follow the second step.


Step 2: Fix Redundant Hostnames With 301 Redirects COPY LINK

This part of the guide is more technical. The following configuration files are sensitive so it is important to make a backup before making any changes. If you can't locate your files or you don't fell comfortable editing them ask your web developer or hosting provider, they should be able to help you without a problem.

Note: Creating these redirections will also help search engine bots to crawl your website more efficiently.

Fix Redundant Hostnames for Apache Server - .Htaccess
To access your .htaccess file, you should go to the root directory in your Cpanel "yourdomain.com/cpanel". Sometimes you have to check "show hidden files".

Once you locate the file add the following lines at the bottom.

Redirect WWW to Non-Www
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.example.com [NC]
RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]
Redirect Non-Www to WWW
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
Fix Redundant Hostnames for Nginx
Nginx is a little more complex than the htaccess. Once you locate the configuration file add the following lines:

Redirect WWW to Non-Www
server {
  server_name www.example.com;
  rewrite ^/(.*)$ http://example.com/$1 permanent;
}
Redirect Non-Www to WWW
server {
  server_name example.com;
  rewrite ^/(.*)$ http://www.example.com/$1 permanent;
}
Fix Redundant Hostnames With WordPress/PHP
If for any reason you can't access your configuration files you can use PHP, this is less efficient than the other two.

Redirect WWW to Non-Www
 <?php
    if ($_SERVER&#91;'HTTP_HOST'&#93; == 'www.example.com'){
       header("Location: http://example.com".$_SERVER&#91;'REQUEST_URI'&#93;);
    }
?>
Redirect Non-Www to WWW
<?php
   if ($_SERVER&#91;'HTTP_HOST'&#93; != 'www.example.com'){
      header("Location: http://www.example.com".$_SERVER&#91;'REQUEST_URI'&#93;);
   }
?>
Step 3: What to Do After Consolidating Your Hostnames COPY LINK

Independently from the method you used, once you have made the necessary changes, go to your Google Analytics click in the redundant hostname notification and click on the blue text "Check Again"

Google Analytics Notifications Check Again - redundant hostnames

This will change the status to pending verification

Google Analytics Notification Pending Verification - redundant hostnames
And after GA confirms that everything it's ok the notification will change to resolved.

Google Analytics Notifications Resolved - redundant hostnames

Osclass Support Forums - Rackons.in

Re: Redundant Hostnames error
« Reply #1 on: January 01, 2018, 01:38:20 AM »