Score:0

Is it possible to have a capturing group in a cname wildcard expression?

in flag

I want to have a wildcard CNAME, but to capture the value of the wildcard:

As an example, a record like this on d1.com:

* CNAME $1.example.com

Would create these mappings:

a.s1.d1.com => a.s1.example.com
a.s2.d1.com => a.s2.example.com

etc

The general issue I have is that CNAME wildcard values only map to one concrete target, but I want the CNAME to map to the same wildcard-matching-subdomain on a different apex/root domain.

My NS is Namecheap, but I can move to get this feature.

Is this possible?

Score:1
us flag

Not on the first level no I don't think so, eg you couldn't have a CNAME on the root of the domain like *.example.com, because CNAME records have to be unique, not just to themselves but (unlike other DNS records) there can't be any other records with the same name, and there will invariably be other records that match.

But you could certainly do that on the subdomain, eg *.s1.d1.com (assuming Namecheap's UI supports it) since s1.d1.com wouldn't necessarily have any other records to conflict with it.

Score:1
fr flag

With standard static zones, no, it is not possible to do anything but a fixed expansion with CNAME.1

You can alias sub-trees using DNAME records:

d1.com. DNAME example.com.

or alternatively

s1.d1.com. DNAME s1.example.com.
s2.d1.com. DNAME s2.example.com.
...

DNAME will act as an alias for all subdomains but not for itself, so it can be placed at any level – including at the domain root next to SOA.


1 (A custom-written DNS responder could do anything by generating CNAMEs on the fly, though – for example, if you were using PowerDNS to run your own authoritative nameservers, you might be able to use its Lua scripting to generate anything you want.)

zino avatar
in flag
Thanks for the suggestion, it is a shame DNAME does not have wider support.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.