0

On my domain example.com, I want to have a generic subdomain test.example.com that point to the folder test, and various cname (es. bar.example.com, foo.example.com) that all points to test.example.com.

I'm using Hetzner as provider, I created an A record (test.example.com) and a CNAME (bar.example.com) that point on the A record, and to make it works I had to add bar.example.com as an addon domain on Hetzner.

Any suggestion? Any possible solution that doesn't involve adding cname to addon domain?

4
  • Why don't you want to use an add-on domain? Any solution is going to involve configuring the webserver. You can't point to the server and choose the document root directory just through DNS. Add-on domains are typically the way to configure shared hosting to set the document root for a subdomain. Commented Feb 16, 2021 at 11:28
  • @StephenOstermiller for many reason, like limited addon domain slot. Also I want this process to be automatic, I can create cname with godaddy api, but i haven't api to create a subdomain each time, so it's annoying to do manually each time Commented Feb 16, 2021 at 15:32
  • Would you consider getting a VPS instead of using shared hosting? It would be pretty easy if you had full control over your own server. I don't think that implementing it on shared hosting without using add-on domains would work. Commented Feb 16, 2021 at 15:34
  • If it is a cpanel server, why not add it as an alias if it is simply pointing to an existing subdomain
    – Steve
    Commented Mar 18, 2021 at 23:04

1 Answer 1

1

I dont know the limits if your provider, but from a technology POV -

Instrad if adding individual CNAMES you can use a wildcard for all subdomains - normally depicted as "*" in DNS servers (ie create *.example.com". I would recommend you use an A record rather then a CNAME because CNAMES re misunderstood.

Nothing you do on DNS can provide a redirect on a web server because any DNS mechanisms used for http are resolved to an IP address by the client and a connection is made to the IP by the server. The client then sends a header to the server advising what domain it is wanting content for.

This means that the server needs to "route" the request as appropriate - so to have the same answer for all subdomains the server needs to recignise them - usually this is done by a default host in the server config - something you likely wont have control of shared hosting.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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