Same as above:

Can I create a CNAME record to point a subdomain to a webpage e.g. blog.example.com -> example.com/blog?

I would also like to know if I can do this to point subdomains to webpages on different websites.

e.g. bluesky.example.com -> bsky.app/profile/example.com

  • chaos@beehaw.org
    link
    fedilink
    arrow-up
    10
    ·
    2 days ago

    CNAMEs can only point to other domains. Redirects like that would be handled on the HTTP level, so you’d need a web server in the mix that sends requesters to the right place when they try to access the subdomain. It can redirect to anywhere, not just domains you control, so the Bluesky example would be handled the same way as the other one.

  • irelephant [he/him]
    link
    fedilink
    arrow-up
    8
    ·
    2 days ago

    No, when you make a http request, the route is a part of the headers. DNS is only the name part.

  • refalo
    link
    fedilink
    arrow-up
    5
    ·
    2 days ago

    Not strictly within the normal way DNS works, no. A CNAME record response can only contain another domain or subdomain name. You would have to run a webserver that listens on the IP that the CNAME record eventually pointed to, in order to handle redirections to a specific URL.

    • twopi@lemmy.caOP
      link
      fedilink
      English
      arrow-up
      2
      ·
      2 days ago

      OK. Is there a web service that does this or do I have to run my own service and make the redirects myself?

      • refalo
        link
        fedilink
        arrow-up
        2
        ·
        20 hours ago

        There is, just google something like “url redirection service” and you’ll find lots. Your domain/DNS provider may already offer one as well.