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

3

2 Answers 2

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.

7
  • 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('polygonhealth.app/') }) module.exports = app; on my local server it seems to redirect but online it seems to stay on the original page Aug 16, 2022 at 15:24
  • On EC2, S3, Fargate, or some other AWS service? Are you using CloudFront with it? Aug 16, 2022 at 15:26
  • on EC2 - I posted the code in an update in my post Aug 16, 2022 at 15:27
  • What are you using for your web server on EC2? Apache, Nginx, or just the node development server? Aug 16, 2022 at 15:28
  • I am using node. I posted an update on what I just tried in my post Aug 16, 2022 at 15:28
-1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.