Fix the Redundant Hostname Warning in Google Analytics

Discussion in 'Windows Know Base' started by securityhope, Jan 16, 2017.

Tags:
  1. securityhope

    securityhope Administrator Staff Member

    Joined:
    Aug 3, 2016
    Messages:
    1,241
    Likes Received:
    0
    Trophy Points:
    36
    Today when I logged into my Google Analytics account, I was greeted with a new warning notification in the Google Analytics notification area. When I clicked the notification, there was a warning message reading “redundant hostnames, property mydomain.com is receiving from redundant hostnames”. Clicking on the Details link below the message would expand the details section with details about the redundant hostname warning in Google Analytics and how to resolve it. In this post, I will show you to fix the redundant hostname warning in Google Analytics.

    [​IMG]

    If you are hearing about Redundant hostname thing for the first time in Google Analytics, then here is a short detail about it.

    In 2014, Google announced a new change in Google Analytics through which the Google Analytics users will be warned if redundant hostnames are linking to their website data or if your website is receiving data from redundant hostnames as described in the warning message.

    If you click the Google Analytics notification and expand the redundant hostname notification details, you will see that the warning message has your own domain but with or without www extension.

    [​IMG]

    What Google is hinting at here is that multiple domains are linking to a single page. When multiple domains point to the same page, Google and other search engines may consider it as a duplicate page with similar contents resulting in a penalty or affecting your website’s ranking.

    For example, if you visit this blog by typing technicalnotes.org or www.technicalnotes.org, both will lead you to the same page that is www.technicalnotes.org. However, at times even though the server responds to both the domains, it will not redirect them to your main domain, and you will be able to access www.yourdomain.com and yourdomain.com as separate domains leading to the same page.

    This will create the duplicate content issue, and you will see a redundant hostname warning in Google Analytics.

    Fix for the redundant hostname warning message in Google Analytics is to ensure that the traffic doesn’t get split between your domains and all the traffic goes to your main domain. This can be achieved by adding 301 redirect rule to your .htaccess file. You can choose www or non-www version as your main domain. However, what is important is that all the site traffic should be redirected to one version, and you should avoid having two versions of the same domain.

    Fix Redundant Hostname warning by adding 301 Redirect Rule to .htaccess File

    To access .htaccess file you should have access to your server either through ssh terminal command or any FTP client such as FileZilla.

    So, login to your server through ssh terminal command or FileZilla and locate the .htaccess file.

    The .htaccess file should be in the public_html folder or your website name folder.

    Create a backup of .htaccess file to your local computer by downloading it.

    Next, right-click on the .htaccess file and click edit.

    Your .htaccess file might look something like this:

    #BEGIN WordPress

    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]

    # END WordPress
    When the .htaccess file opens, add the following line of rules to it:
    RewriteEngine On (if this line exists, then don't add this line again).
    # Rewrite all requests to the 'www' version
    RewriteCond %{HTTP_HOST} ^mydomain\.com$ [NC]
    RewriteRule ^.*$ http://www.yourdomain.com%{REQUEST_URI} [R=301,L]
    Note: Replace yourdomain.com with your domain name address.
    Save the file by pressing Ctrl S and close the editor. Now upload the edited .htaccess file to the server.
    After the edit, your .htaccess file will look like this:
    # BEGIN WordPress

    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^yourdomain\.com$ [NC]
    RewriteRule ^.*$ http://www.yourdomain.com%{REQUEST_URI} [R=301,L]
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]

    # END WordPress

    Now check whether the both the versions of the domain leads to the main domain that is if your main version is www.yourdomain.com then you should be redirected to www.yourdomain.com even if you type yourdomain.com in the address bar.

    Once confirmed, go to back to Google Analytics, click on Redundant hostname warning message and click on Check again link.

    It may take up to 24 hours before Google checks and updates the warning message as solved.
     
    Last edited: Jan 18, 2017

Share This Page

Share