Network Reviews

How To Fix Redundant Hostnames In Google Analytics

If you are here looking forward to knowing how to fix redundant hostnames notification in Google Analytics or others, then you’re on the right page. On this page is all you should know about the Redundant Hostnames error.

If you get Google Analytics redundant hostnames error. First, this will have you create a search and replace the filter that strips www from hostnames in Google Analytics. There are a few technical changes, but it comes down to personal preference in the end.

Also Read: How To Fix Internet Connection Problem On Android And iOS Devices.

What is Redundant Hostnames?

Redundant Hostnames means that Google Analytics is tracking your domain in two places independently. For example, the domain name www.example.com and example.com will appear to be different in Google Analytics.

And this also means that your pages will be split across the two URLs even if they provide the same content. The Redundant Hostnames Notification in Google Analytics let you know so as to prevent this by consolidating both domains into one.

How to fix redundant hostnames notification in Google Analytics

Before proceeding in resolving the redundant hostnames in Google Analytics, you’ll have to decide if you prefer to show your domain with or without WWW.

So, if you’re receiving the redundant hostname notification in Google Analytics, it means that Google Analytics is tracking your domain two places independently.

Consider the URL of this post for example, Google Analytics would be tracking them as 2 different pages:

www.genguide.com.ng/redundant-hostnames-google-analytics

genguide.com.ng/redundant-hostnames-google-analytics

If you got the Google Analytics redundant hostnames error notifications, here is a quick fix for Redundant Hostnames with a Filter in Google Analytics.

How To Fix Redundant Hostnames

Now, here is how to solve the redundant hostname warning in Google Analytics

This will help to combine your hostnames in Google Analytics quickly. To fix the redundant hostnames notification in Google Analytics, follow the steps:

  • Log in Google Analytics.
  • Go to the Admin section.
  • Click on Filters / All Filters on the 3rd column VIEW.
  • Then, click the red button +Add Filter.
  • Enter the Filter Name in the field (e.g My Redundant Hostname).
  • Select Custom for filter type.
  • Next, on the list, select Search and Replace.
  • In the Filter Field, select hostname.
  • In the Search String, enter ^www\. while in the Replace String, leave it empty.
  • Scroll down and click on Save.

How to Fix redundant hostnames on Apache server (.htaccess)

To fix redundant hostnames on Apache server, you’re to access your .htaccess file. To do this, you should go to the root directory in your Cpanel “yourdomain.com/cpanel”. Also, sometimes you’ll have to check “show hidden files”.

If locate the file, add the following lines at the beginning of the file.

To Redirect www to non-www

For HTTPS sites

<IfModule mod_rewrite.c>

RewriteEngine On

RewriteCond %{HTTPS} off [OR]

RewriteCond %{HTTP_HOST} ^www\.example\.com [NC]

RewriteRule (.*) https://example.com/$1 [L,R=301]

</IfModule>

For HTTP sites

<IfModule mod_rewrite.c>

RewriteEngine On

RewriteCond %{HTTP_HOST} ^www.example.com [NC]

RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]

</IfModule>

To Redirect non-www to www

For HTTPS sites

<IfModule mod_rewrite.c>

RewriteEngine On

RewriteCond %{HTTPS} off [OR]

RewriteCond %{HTTP_HOST} !^www\. [NC]

RewriteCond %{HTTP_HOST} ^(.*)$ [NC]

RewriteRule (.*) https://www.%1/$1 [R=301,L]

</IfModule>

For HTTP sites

<IfModule mod_rewrite.c>

RewriteEngine On

RewriteCond %{HTTP_HOST} ^example.com [NC]

RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]

</IfModule>

Also, read this advanced guide on htaccess for more information.

How to fix Redundant Hostnames with 301 Redirects

To fix Redundant Hostnames with 301 Redirects is more technical when compare to that of Google Analytics. The following configuration files are sensitive so it is important to make a backup your website before making any changes.

But, if you’re having trouble finding your configuration files or don’t feel comfortable modifying Redundant Hostnames with 301 Redirects, do contact your web developer or hosting provider; they should be able to assist you without issue.

After you’ve made the modifications, try them in a new incognito window to see if your site is functioning properly and that all redirections are working.

Do note that creating these redirections will also help search engine bots to crawl your website more efficiently.

How to Fix redundant hostnames on Nginx

Nginx is a little more difficult to work with than htaccess. Add the following lines to the configuration file once you’ve found it:

To Redirect www to non-www on Nginx

Redirect WWW to non-www type the following code in file if locate:

server {

  server_name www.example.com;

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

}

To Redirect non-www to WWW Nginx

If you want to redirect non-www to WWW, use the following code below:

server {

  server_name example.com;

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

}

How to Fix Redundant Hostnames with WordPress / PHP

If you can’t access your configuration files for some reason, you can use PHP, which is less efficient than the other two options.

To Redirect WWW to non-www on WordPress / PHP

 <?php

    if ($_SERVER&#91;’HTTP_HOST’&#93; == ‘www.example.com’){

       header(“Location: http://example.com”.$_SERVER&#91;’REQUEST_URI’&#93;);

    }

?>

To Redirect non-www to WWW on PHP / WordPress

<?php

   if ($_SERVER&#91;’HTTP_HOST’&#93; != ‘www.example.com’){

      header(“Location: http://www.example.com”.$_SERVER&#91;’REQUEST_URI’&#93;);

   }

?>

What to Do After Resolving Your Redundant Hostnames

Regardless of the approach you chose, once you’ve made the necessary modifications, go to Google Analytics and click on the blue text “Check Again” under the redundant hostname message.

After that, it will change the status to pending verification, then Google Analytics will confirm that everything is ok and the notification will change to “resolved”.

Now that you’ve found out what Redundat Hostnames is all about, have you fixed yours? As this guide stands to teach you how to fix Redundant Hostnames in Google Analytics, Apache, Nginx, WordPress, PHP, and others. You can see I also point out how to redirect from WWW to non-www and also to redirect from non-www to WWW.

Related Topics:

How To Fix Incoming Call Busy Problem – 7 Ways

How To Fix Internet Connection Problem On Android And iOS Devices

I Can’t Install Apps On Play Store

Why Is Facebook Not Opening

Leave a Reply

Your email address will not be published. Required fields are marked *