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

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

9 points · 6 comments · view on lemmy.world

6 Comments

irelephant@programming.dev · 8 pts · 1y

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

clmbmb@lemmy.dbzer0.com · 6 pts · 1y

That's being done with a reverse proxy.

superb@lemmy.blahaj.zone · 5 pts · 1y

Easiest way to accomplish what you want: host a static html page on blog.example.com that redirects the user to example.com/blog:

https://stackoverflow.com/questions/5411538/how-to-redirect-one-html-page-to-another-on-load

I’ll note that a server side redirect would be preferred if this is for professional or business use. For personal shit, go nuts

refalo@programming.dev · 5 pts · 1y (2 replies)

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.ca · 2 pts · 1y (1 reply)

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

refalo@programming.dev · 2 pts · 1y

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