Let's say I have an online service for webmasters at example.com. My service presents a web app to be used by the visitors to the websites owned by my webmaster clients. The web app lives at mywidget.example.com. Clients can create links to mywidget.example.com so their visitors can use the web app.

However, some clients will want to use their own custom subdomain to get to the web app. So, they can create a CNAME such as widget.clientdomain.tld and point it to mywidget.example.com. That works fine except visitors still see mywidget.example.com in the browser address bar instead of widget.clientdomain.tld.

What do I need to do to get client custom subdomains to appear in the visitor's address bar instead of mywidget.example.com?

  • Your customers would just simply create a CNAME record in their DNS that points widget.clientdomain.com to mywidget.acmewidgets.com.
    – closetnoc
    Oct 1, 2016 at 0:17
  • Thanks, @closetnoc. I checked again and found a configuration issue.
    – Bob Arlof
    Oct 1, 2016 at 2:47

1 Answer 1


Once your clients point the subdomains at your service, you need to configure your web server to use their subdomain rather than your own. You could use this rewrite rule in .htaccess to ensure that only the client subdomain will appear in the address bar. Other host names pointed to the service (including your own subdomain) will redirect:

RewriteCond %{HTTP_HOST}   !^widget\.clientdomain\.tld [NC]
RewriteCond %{HTTP_HOST}   !^$
RewriteRule ^/(.*)         http://wiget.clientdomain.tld/$1 [L,R]
  • Thanks Stephen. I ended up placing the files that support the service in an AWS S3 bucket and then allow clients to access those files via CloudFront. A new client can create a CNAME record for their custom subdomain and point it to my CloudFront distribution. I then add that subdomain the CloudFront distribution's list of "alternate domain names". At that point, the service's files can be accessed via the client's subdomain and that subdomain is what appears in the browser's address bar.
    – Bob Arlof
    Oct 3, 2016 at 0:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.