To handle Canonical URL is it best practice to do a 301 redirect or better to have the same IP Address for both www and non www domain?
For example:
Canonical URL/domain wanted is http://example.com
Domain | A Record
------------------------------------
example.com | 192.0.2.34
www.example.com | 192.0.2.34
I understand people may have a CNAME record for www (alias, given that CNAME is called Canonical Name); unsure if this is best practice compared to using the same IP address.
Or is this better.
Domain | A Record
------------------------------------
example.com | 192.0.2.34
* www.example.com 301 redirect to example.com