How to setup a custom domain to a SAAS?

I’m building a SAAS product with PHP/HTML on shared hosting on a Linux server and I’m stuck on the domain name part.

Goals

I would host my SAAS app on app.mysaas. com

My customers point their domain name to app.mysaas. com

  • www.customer01. com
  • www.customer02. com
  • www.customer03. com
  • etc…

Any visitors on the customer’s domain should be served content from app.mysaas. com without them noticing, meaning they see www.customer01. com in their browser.

Also when visiting www.customer01. com/contact they should be served content from app.mysaas. com/contact/ without them noticing, meaning they see www.customer01. com /contact/ in their browser.

SEO on the customer’s domain should not be affected as read in the article https://smartclick.mk/seo-for-saas-and-best-optimising-practices/. So via iframe isn’t an option.

I would need my customer to provide an API key. I thought I let my customer add a TXT record to their DNS containing their API key and pick it up with PHP on my server.

Questions

  • Should they point their domain via DNS using an A record or a CNAME record? (Their e-mail setup should not be affected.)
  • How do I detect the customer’s domain pointing to app.mysaas.com ? (I thought with PHP’s var $_SERVER['HTTP_HOST'] )
  • If I’m way off, could you provide a step by step guide please?
  • Are there any good online tutorials ?

Thank you for you time.

Both would work, but in keep in mind that setting a CNAME on a naked domain is a very bad idea, it breaks email.

Yes, $_SERVER['HTTP_HOST'] works

TXT records are public record, so that may not be the smartest idea.
Maybe keep a list of known domains that are allowed to use your app and then check that against $_SERVER['HTTP_HOST']? If the domain is unknown just show a 404 error page.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.