How to redirect to another domain?

Hello Support team and Community, this is more of a general question.

I have a domain thats bought from NameCheap and the website is hosted on WordPress. Now I want to redirect everything in that domain to another domain that has a Github repository and is linked to Netlify.

Is it possible if i create a new site in Netlify and add only the netlify.toml file and then add the custom domain that is bought in WordPress to that site, would it redirect?

So as an example in NameCheap I bought two domains:

“https://wordpresshosteddomain.com/”
“https://www.netlifyhostedwebsite.com/”

In Netlify, I already have a site setup for this domain “https://www.netlifyhostedwebsite.com/”. Now I want to redirect the wordpresshosteddomain to the one in Netlify.

So after reading the documentation, I understood I can simply setup a new site that would only contain the netlify.toml link it to the custom domain “https://wordpresshosteddomain.com/” and in the file I can add the following, and it should work:

# Fallback Redirect
[[redirects]]
from = "https://wordpresshosteddomain.com/*"
to = "https://www.netlifyhostedwebsite.com/"
status = 301

Would this redirect to the website hosted in Netlify?

@p-haddad Provided that the domain that is currently pointed at the Wordpress site is instead pointed at Netlify, then yes you could create a Netlify site for it and use that site only as a redirect.

1 Like

Yes for sure it would be pointing to Netlify, I would add the nameservers provided by Netlify under that domain in NameCheap so it links to Netlify. But just to be sure it would still be used as a redirect even if the repository only contains the netlify.toml file and no other file, right? That shouldn’t be a problem i think, what i mean is that no other configuration is needed then.

It should, but I can’t remember the specifics myself.

If you found that you did need to add another file like a blank index.html it wouldn’t hurt anything.

You just may need to use a redirect with force.

1 Like