Is it possible to have a CNAME DNS record point to a URL with a path?
DNS records alone cannot do what you want. DNS records only point host names to IP addresses (or in the case of CNAMEs to other host names).
You have to configure your server to handle it correctly.
One way is to issue redirects. I presume that you think that is ugly because the URL changes.
Another way is to set up "virtual hosts" with different content for each of these host names. I've never used Heroku before, but it appears that you can add multiple custom domains to it: https://devcenter.heroku.com/articles/custom-domains
In a single application with multiple host names pointed at it you can usually discern the host name and program your application to act accordingly. I haven't been able to figure out how to do so in Heroku, but it should be part of the HTTP Request. It is sent as the Host:
HTTP header.
Related videos on Youtube
dwjohnston
Updated on September 18, 2022Comments
-
dwjohnston almost 2 years
I've registered several domains for my nieces and nephews, the idea being to create small static webpages for them, so they can say 'look at my website!'.
In terms of hosting it, I'm using expressjs on Heroku, to serve up static pages.
What I'm wanting to do is have:
http://suzy-derkins.space --> my-herokuapp.herokuapp.com/static/suzy http://calvin-is-trouble.space --> my-herokuapp.herokuapp.com/static/calvin
Now I can user a CNAME record to point each of my domains at
my-herokuapp.herokuapp.com
, but a CNAME record won't allow a full URL.I could add an unmasked redirect, so that
http://suzy-derkins.space
redirects tohttps://suzy-derkins.space/static/suzy
, but that's ugly.I don't want to use a masked URL redirect - as that causes problems on mobile, and also the user presses any links, the new page remains masked.
I'd also like to retain the ability to add additional pages, for example:
http://my-herokuapp.herokuapp.com/static/suzy/my-favourite-things
be represented byhttp://suzy-derkins.space/my-favourite-things
.What kind of records do I use to do this?
-
dwjohnston over 7 yearsHi thanks. It looks like that heroku documentation link is what I'm looking for.