Hi there,

My question isn't strictly about programming, it's primarily a question of how to approach my problem with the tools I have.

I am building a website where a user can sign up and create their own profile/portfolio so to speak. Let's say this is mysite.com. Say Joe Bloggs signs up so his profile/portfolio would then exist at mysite.com/joebloggs. Joe decides he would rather use his own domain name joebloggs.com for his profile/portfolio.

I know that in web application I can of course check the $_SERVER variables to find the incoming domain, check a database mapping and act accordingly.

I'm pretty sure that if I had complete control over a server I could set it up just fine so that if Joe was to change his CNAME DNS record to point at mysite.com I could essentially just accept any incoming request and process everything through my application.

However, I intend to use shared hosting. I just wanted to know if the above could be achieved on a shared host without the need to manually add domains to my hosting that point at my web application? If this is not possible, could I work around it somehow? Even if it means some initial messing around for the user.

Thanks,
Jonathon

Dani AI

Generated

Short answer: on most shared-hosting plans it's not possible to accept arbitrary third-party hostnames automatically — the host's webserver only hands requests to accounts for hostnames that appear in its virtual-host configuration. That means each mapped domain usually needs to be added to the hosting account (parked/addon) or the host must enable a wildcard ServerAlias for the account. ' idea of routing by Host is correct in application logic, but the webserver layer must first accept that Host header.

Practical options and trade-offs:

  • Stay on shared hosting: ask the provider whether they support parked domains added by API or a wildcard alias for the account; require domain-ownership proof via a DNS TXT or upload token; then add the domain in the control panel and record the mapping in the app. Note that apex domains cannot be CNAMEd (use A or ANAME/ALIAS at registrar).
  • Short-term hacks: registrar URL-frame or iframe masking — discouraged (SEO, cookies, security).
  • Recommended: move to a server or platform that supports custom-domain mapping (VPS/reseller, or PaaS/CDN providers that automate mappings and SSL). This aligns with 's suggestion and removes most operational friction.

Implementation notes:

  • Use DNS TXT verification to confirm ownership before making host changes.
  • After host-level mapping exists, map Host -> user in the app (example in PHP):
    $host = strtolower(preg_replace('/^www\./','', $_SERVER['HTTP_HOST']));
    $user = $db->fetchOne('SELECT id FROM domain_map WHERE domain = ?', [$host]);
    if ($user) { /* load user's profile */ }
  • SSL: each custom domain needs a certificate. Automating via ACME (DNS-01 for apex/wildcard) or using a platform that provisions certs is strongly advised.

Bottom line: on shared hosting this usually requires host cooperation or manual adds; the most robust path is a server/platform with full control or built-in domain-mapping support.

i would look for a virtual server with full control for my site
prices should be roughly the same

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.