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
+21.2k Generate checksum for a file in Go
+12.6k Golang : Compress and decompress file with compress/flate example
+39.7k Golang : How to check if a string contains another sub-string?
+3.1k Golang : PGX CopyFrom to insert rows into Postgres database
+24.6k Golang : missing Mercurial command
+7.3k Golang : How to check if input string is a word?
+5k Fix ERROR 2003 (HY000): Can't connect to MySQL server on 'IP address' (111)
+11.4k Golang : Get absolute path to binary for os.Exec function with exec.LookPath
+29.8k Golang : Convert an image file to []byte
+7.1k Golang : Variadic function arguments sanity check example
+9.6k Golang : Fix go.exe is not compatible with the version of Windows you're running
+13.8k Golang : Basic authentication with .htpasswd file