1

I'm trying to use an A record to redirect my domain to a separate domain that I own. This process has worked fine with DigitalOcean Droplets -- I just add their IPv4 address in the A record and the request goes straight through to whatever the Droplet is hosting.

However, the website I'm trying to send the request to is operated with shared hosting, so the IP address I got by pinging my website is actually a broader one that does not link to the website, but rather a landing page for anybody who uses the server that the site is hosted on.

I get the same thing while trying to use a GitHub Pages/Cloudflare pages site -- just 404s as I'm probably querying the underlying server and not the webpage they're being served on.

My question is two-part:

  1. Why does this work on DigitalOcean and not GitHub/Cloudflare? I was under the assumption that Droplets are shared hosting as well, but maybe not...?
  2. Is there any other way to do a redirect/have a page hosted without having to buy an entire separate droplet?
Andrew
  • 13
  • 2

1 Answers1

1

How do you set an A record for any shared host?

You set an A record for a shared host the same way as you do for any other host, there is no difference, you use the correct IP-address(es) and you're done.

But there's several issues there and you're probably asking the wrong question:

  • Unless the shared hosting platform both explicitly supports adding additional/custom domains to existing hosting plans and you have registered your new domain in your hosting plan, the platform won't actually recognise your additional domain.
    Generally shared platforms need to be configured to associate domain names with specific accounts and otherwise won't respond correctly as evidenced by the generic landing page that gets displayed.

  • I imagine that a shared hosting platform won't provide you with a "correct IP-address" for you to use in your A record in the first place, as they'll be using a CDN service and/or will want to be able to change IP's at will without breaking your hosting. (Often they'll recommend setting up a CNAME record instead of an A record, with the problem that CNAME's can't be used for a bare domain / apex.

This process has worked fine with DigitalOcean Droplets. Why does this work on DigitalOcean and not GitHub/Cloudflare? I was under the assumption that Droplets are shared hosting as well, but maybe not...?

Probably because you never configured a default landing page on your droplets. When you don't explicitly configure a landing page (in web server jargon: "default virtual host") the first/only website becomes the default web site that will always get displayed.
That site will not only show when the correct site name is used, that will also be the site shows when for example the bare IP-address of the server is used, or also when any random, unknown domain name that gets pointed at your server's IP-address is used.

Is there any other way to do a redirect/have a page hosted without having to buy an entire separate droplet?

Use name based virtual hosting on an existing droplet of yours.

HBruijn
  • 77,029
  • 24
  • 135
  • 201
  • Thanks! I see -- that makes much more sense that the droplets are simply forwarding all traffic to whatever I had configured + the platform would want the flexibility to change the IP if they wanted to. I know some platforms offer 'dedicated IPs', would those (in this context) just be unchanging addresses? – Andrew May 30 '23 at 17:14
  • Possibly. That depends on the platform and use-case. – HBruijn May 30 '23 at 17:43