Scenario: I have salesforce community to run on custom domain e.g. ‘www.xyz.com’. But this should also work without ‘www’ (naked domain) i.e. ‘xyz.com’.
Solution: Goto to domain management (considering Godaddy here, but same applies to other providers as well including cpanel tool.). Add domain forwarding on Godaddy (it is at the bottom right of the page). Fill-in ‘www.xyz.com’ in ‘Forward to’ field. Choose other values as per requirement. And save it. Now if any one will open ‘xyz.com’, it will get redirected to ‘www.xyz.com’.
*To setup custom domain, go through salesforce documentation url: https://help.salesforce.com/articleView?id=domain_mgmt_add.htm&type=0