Got a new domain name for our website and want to redirect the old domain to the new one, but we don't have web hosting for the SSL/HTTPS? Easy, we can use the free service Cloudflare provided.
Nerdizen.xyz — Redirecting domain is of course can be done easily on our domain's registrar platform from the provided tools there e.g., the DNS settings.
But what if we want to also redirect the SSL/HTTPS version of our website, but we don't have way to setup it because we don't have a web hosting? Cloudflare is the solution!
If we park our domain on Cloudflare, it provides the SSL encryption to secure the connection using the HTTPS protocol, so redirecting HTTPS is working without a hassle.
Moreover, Cloudflare is generous enough, even the free plan is great and SSL/HTTPS connection is available on their free plan.
Steps redirecting a domain to another one with SSL/HTTPS on Cloudflare
Changing nameservers, parking old domain to Cloudflare and enabling the HTTPS connection
- Log in to the Cloudflare's dashboard and add our domain/website.
- When selecting the plan, choose suit us. Of course here I will be using the Free plan. 😋
- It will ask to change the nameservers to the one Cloudflare's provided.
- Go to our original domain's registrar, for example here I am using Namecheap, and set the custom nameservers to the one Cloudflare provides, example for me:
-kami.ns.cloudflare.com
-paul.ns.cloudflare.com
- Wait. Nameserver changes often won't take instantly and can take up to 48 hours. We can check back every 30 minutes and refresh the Cloudflare domain/website page to see if the status is changed to "Active".
- After the status is changed to "Active", delete unused DNS records. Click the "DNS" menu on the sidebar, it will take us to the "Records" sub menu.
- Scroll down and delete all records with "A" or "CNAME" Type column that has Name column of our domain's root or
www
. Click "Edit" on the Action column of the record, then click "Delete" button on the bottom.
- Next enabling the HTTPS connection, click the "SSL/TLS" menu on the sidebar, and set the mode to "Flexible".
- Back to the DNS menu, we'll add Cloudflare's DNS records to our domain. Click "Add record", then add two new A records:
a.) Type:A
| Name:@
| IPv4 adress:192.0.2.1
| Proxy status: enabled.
b.) Type:A
| Name:www
| IPv4 adress:192.0.2.1
| Proxy status: enabled.
Click "Save" on the button to save the each new records.
Redirect naked/root domain
- Expand the "Rules" menu on the sidebar by clicking the arrow icon → "Redirect Rules" → Click "Create rule" button.
- On the "Rule name" input, create a descriptive name, e.g.,
Redirect to www.mynewdomain.com
. - Scroll down to the "When incoming requests match..." section and fill the fields, example:
a.) Field:Hostname
b.) Operator:equals
c.) Value:mycurrentdomain.com
- Scroll down to "Then..." section and fill the fields:
a.) Type:Dynamic
b.) Expression:concat("https://mynewdomain.com", http.request.uri.path)
c.) Status code:301
d.) Tick the "Preserve query string". - Click "Deploy" button on the bottom right.
Redirect www version and other subdomain
- Go to "Redirect Rules" sub menu under the "Rules" menu on the sidebar (still on the same menu from the previous steps).
- Scroll down to "Bulk Redirects" section and click "create a bulk redirect list".
- On the Name input, type desired name, it can only contain letters and underscores, e.g.,
www_currentdomain_com_to_newdomain_com
, click "Next". - On the "Add URLs to redirect" section, click "Or, manually add URL redirects", it will pops out the record fields and fill it, example:
a.) Source URL:www.currentdomain.com
b.) Target URL:www.newdomain.com
c.) Status:301
- Click the "Edit parameters" to show additional settings and tick it all:
- Preserve query strings
- Include subdomains
- Subpath matching
- Preserve path suffix - Click "Next" on the bottom, → "Next" again on the Review and edit URL redirects, → "Continue to Redirect Rules".
- Give a descriptive name on the Rule name input, e.g.,
www.currentdomain.com to newdomain.com
, click "Save and Deploy".
That's conclude our tutorial how to redirect our old domain with its HTTPS version to new domain without web hosting using Cloudflare, for free.
Don't forget to test the redirection using a new private window to bypass browser's cache or use fresh browser that haven't visited our old domain before.
Emoticon Emoticon