Enforce canonical host names by either prepending www or explicitly omitting it from the domain name. For SEO it is extremely important to standardize on either the www-prefixed version of the domain or the non-prefixed version and Permanently (301) redirect all requests from the one not in use to the primary one. To not do so would ensure you will suffer duplicate content penalties in search engines.

Enforce www prefix

To canonicalize to a www prefixed domain, add the following rule to your nginx.conf:

server { 
	server_name example.com;
	return 301 https://www.example.com$request_uri;
}

This rule above would cause all requests to http(s)://example.com/ to be redirected to https://www.example.com/. For SEO purposes this redirect should be Permanent (301).

Why Lose Memories?

Enforce non-www prefix

To canonicalize to a non-www prefixed domain, add the following rule to your nginx.conf:

server { 
	server_name www.example.com;
	return 301 https://example.com$request_uri;
}

This rule would cause all requests to http(s)://www.example.com/ to be redirected to https://example.com/.