1

I have a domain hosted on AWS (www.example.com) and it works fine. I have now a temporary need to route traffic from this domain to a temporary Wix hosted domain (www.example.net). I've tried making a CNAME to simply route from www.example.com to www.example.net (see attached) but it doesn't seem to work. It just either loads the original webpage (when I exclude the "www"), or shows a generic wix error page "Looks Like This Domain Isn't Connected To A Website Yet!", even though the new website loads fine when I type in the new domain.

What I've tried (I am using nodeJS with express).

I went to my app.js in my node server and changed the code to this:

var app = express();
app.get('*', (req, res) => {
  // REDIRECT goes here
  res.redirect('https://www.example.net/')
})

module.exports = app;

when I run the server locally (localhost:5000) the redirect seems to be fine, but with I pull the code to the server and type the domain (www.example.com) it still points to the original website

2 Answers2

0

There is no way to cause one domain to redirect to another using DNS alone. A CNAME is not a redirect. Implementing it will not cause the URL to change. It will only cause the domain to resolve to the same IP address as another domain. See Does pointing a URL via CNAME to another domain redirect via endpoint?

So when you have a CNAME pointing to the other domain, Wix will get the requests for both domains. It won't automatically know how to handle your old domain. You would need to tell Wix what to do. Wix has instructions here for setting up that domain to redirect: Setting Up a 301 Redirect from One Domain to Another | Help Center | Wix.com

Alternately you could implement the redirect with your current hosting on AWS. There are many ways to host something on AWS and you don't say which you are using, so it is difficult to give you precise instructions.

You could also point the domain to some other third party to do the redirect. I like to use Cloudflare to redirect domain names because they will do so for free and they automatically handle the SSL certificates so HTTPS for the redirect works. The downside is that is more complicated to set up than other solutions. I have written complete instructions here for setting up Cloudflare domain redirects.

Stephen Ostermiller
  • 98,758
  • 18
  • 137
  • 361
  • I am using nodeJS with express. I searched online and tried to use the following:

    var app = express(); app.get('*', (req, res) => { // REDIRECT goes here res.redirect('https://www.polygonhealth.app/') })

    module.exports = app;

    on my local server it seems to redirect but online it seems to stay on the original page

    – somethingstrang Aug 16 '22 at 15:24
  • On EC2, S3, Fargate, or some other AWS service? Are you using CloudFront with it? – Stephen Ostermiller Aug 16 '22 at 15:26
  • on EC2 - I posted the code in an update in my post – somethingstrang Aug 16 '22 at 15:27
  • What are you using for your web server on EC2? Apache, Nginx, or just the node development server? – Stephen Ostermiller Aug 16 '22 at 15:28
  • I am using node. I posted an update on what I just tried in my post – somethingstrang Aug 16 '22 at 15:28
  • I've never done node development, so I'm not going to be much help debugging your deployment. It seems likely that it is a caching issue. Maybe on the server, but maybe in your browser. – Stephen Ostermiller Aug 16 '22 at 15:31
  • It is very common to use ngnix or apache as a reverse proxy in front of node on your EC2 server so that they can serve static files and implement redirects. Adding CloudFront on AWS would be another layer you could add that would allow you to implement redirects. – Stephen Ostermiller Aug 16 '22 at 15:33
0

The answer was in load balancers. I can redirect via expressJS script in my app.js file and then route all traffic AWS load balancers to port 5000 where the express server listens to.