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
+29.5k Golang : How to declare kilobyte, megabyte, gigabyte, terabyte and so on?
+10.1k Golang : Wait and sync.WaitGroup example
+5.7k PHP : Get client IP address
+40.7k Golang : How to check if a string contains another sub-string?
+9.4k Golang : Quadratic example
+6.7k Golang : Calculate BMI and risk category
+7.3k Golang : Handling Yes No Quit query input
+18.7k Golang : Read input from console line
+8.1k Golang : Number guessing game with user input verification example
+14.6k Golang : How to check for empty array string or string?
+18k Golang : Get path name to current directory or folder
+9.1k Golang : Terminate-stay-resident or daemonize your program?