Fix Google Analytics Redundant Hostnames problem
Google Analytics alerted me to a "redundant hostnames" problem today. From the message, appparently, Google Analytics is receiving data streaming from two version of my website instead of one, the non-www and the www version.
To fix this problem, I need to tweak the NGINX configuration from this :
server {
listen 80;
server_name socketloop.com www.socketloop.com;
return 301 https://www.socketloop.com$request_uri;
rewrite ^ https://www.socketloop.com$request_uri? permanent;
to this :
server {
listen 80;
server_name socketloop.com;
rewrite ^/(.*)$ https://socketloop.com$request_uri? permanent;
Instead of two server names, now it has only one with the new server_name socketloop.com;
NGINX parameter and redirect every request to the https
version with the rewrite ^/(.*)$ https://socketloop.com$request_uri? permanent;
parameter.
After Google Analytics re-verify the new configuration, the problem is now marked as resolved.
Hope this tutorial may be useful to you.
Reference :
By Adam Ng
IF you gain some knowledge or the information here solved your programming problem. Please consider donating to the less fortunate or some charities that you like. Apart from donation, planting trees, volunteering or reducing your carbon footprint will be great too.
Advertisement
Tutorials
+7.9k Golang : Scan files for certain pattern and rename part of the files
+10.1k Golang : Read file and convert content to string
+8.6k PHP : How to parse ElasticSearch JSON ?
+31.3k Golang : Calculate percentage change of two values
+7.9k Swift : Convert (cast) String to Double
+7.6k Golang : Rename part of filename
+17.7k Golang : Clone with pointer and modify value
+7.3k Javascript : How to get JSON data from another website with JQuery or Ajax ?
+9.4k Golang : How to control fmt or log print format?
+14.7k Golang : How to check if your program is running in a terminal
+15.4k Golang : How to get Unix file descriptor for console and file