- Published on
Permanently Redirecting Old Domain to New Domain in Cloudflare
- Authors
- Name
- Ashik Nesin
- @AshikNesin
Recently, I've started a new blog focusing on AI. And I started it in https://ai.nesin.io domain.
But today I've got a new domain for it AIEngineerGuide.com
To avoid broken links and to avoid getting penalized by Google for duplicate content, I've set up a permanent redirect from the old domain to the new domain.
Here is how I did it within Cloudflare itself using the Page Redirect feature.
- Point your domain to
192.0.2.1
with proxy (orange cloud) enabled. It is cloudflare ip address which is used for redirecting to new domain.
In case, if you are redirecting the root domain (example.com) then use @
for the name. In my case, I'm redirecting the subdomain (ai.nesin.io), so I've mentioned it as ai
- Then, go to Rules -> Templates in the navbar and choose Redirect to a Different Domain template.
- Now, configure the hostname (your old domain) and redirect expression
concat("https://new-domain.com", http.request.uri.path)
. Make sure Preserve query string option is enabled and the status code is 301.
- Then, click on Deploy
That's pretty much it.
Reference
Happy redirecting domains 🎉