"Redundant Hostnames" on Google Analytics: How I fixed it

While looking at this blog’s stats on Google Analytics, I was greeted with a “Redundant Hostnames” warning. Search consoles, Adsense and Analytics errors freak me out. You see, after years of managing websites, I’ve developed some kind of paranoia over site management errors.

Anyway, what came with the warning are four actions: Adjust filter, Check again, Ignore and Details.

Clicking on Details will reveal more information about the problem along with recommended actions on how to fix it.

Redundant hostnames details

The info provided is spot on and reflects the recent changes I’ve made to the site. A month ago, I migrated this blog from Knownhost to DigitalOcean. With the migration is a change in web server from Apache to Nginx. As this blog is powered by ModX, all the necessary redirects were handled by an .htaccess file, which doesn’t work on the new server.

I did configure the barest minimum of Nginx to get ModX’s friendly URLs to work but forgot to set the correct redirections of the root domain. This was what caused the Redundant Hostnames issue.

Figuring this out was half of the fix. The rest is simply to put the correct redirections in place. All I really had to do was to edit the Nginx conf for the domain and define a server for neilyamit.com, then redirect it to www.neilyamit.com. This is the code,

server {
    server_name neilyamit.com;
    return 301 http://www.neilyamit.com$request_uri;

server {
    server_name www.neilyamit.com;

After testing if it redirects to the correct URL, all I had to do was click Check again. It took almost a day for the warning the issue to be resolved.

Redundant hostnames resolved

Now, you must understand that the fix depends entirely on how your site is configured. The above code will only work if a website is running on top of Nginx; different servers will require different snippets of code or configuration. But the central idea is the same, just make sure that only one hostname pass data to Google Analytics. If you’re not familiar with tweaking the server config of blog or website, contact your web developer.