[SalesForce] How to set a custom domain in a Salesforce community

Background

We have a salesforce community called mycompany.force.com/
We also have a custom domain: mycompany.my.salesforce.com where users have Company Community Licenses. Because my users have that license which is a special one, they cannot log in from the standard community login page and that is why we created a custom domain (to create a custom login page and redirect users to the community). From our custom login page, we redirect users to our community.

The problem arose when we created a CNAME pointing to our custom domain; instead of taking us to the custom login page, it is redirecting us to the standard Salesforce login (so users cannot login to the community).

We have tried several things to fix this issue:

  1. Create a CNAME pointing to MyCompany.force.com.
    This is redirecting to na1.salesforce.com (Instead of going to my community login page)

  2. Create a CNAME pointing to MyCompany.OrgID18.live.siteforce.com
    My domain name has a TXT record that equals 00XXX000000ivokeac with no punctuation.
    My domain name is a subdomain of an another domain in my organization.
    This redirects me to https://na1.salesforce.com/.

Nothing seems to work though.
Any ideas on anything else we can try?
Thank you!

Best Answer

@CamilaHeitz Let me try to explain with an example. As you mentioned yourdomain is a subdomain of another domain, so I am referring your domain as subdomain.

  1. First create a CNAME record for http://subdomain.maindomain.com as subdomain.maindomain.com.orgid18.live.siteforce.com.
  2. After the CNAME is created in DNS server, add the domain in your org Setup > Domain Management > Domains > "Add a domain".
  3. As per Salesforce you have to use a certificate, make sure you’ve already added it using Certificate and Key Management before you try to attach it to your domain. Details available in Aidan's link.
  4. After adding the domain go to Setup > Develop > Sites. Open your community site in edit mode by clicking on Site Label. Add "New Custom URL" by selecting http://subdomain.maindomain.com from the list. I think you are missing this step.

Hope this will helps.