Domain name providers like Godaddy allow you to easily forward your domains. However if you use cloudflare you can accomplish the same thing just with an extra step using page rules.
If you use the basic URL redirect for the whole domain like olddomain.com, then you lose anything else in the URL like the specific page a user was trying to visit such as olddomain.com/about-us
So if you set up the page rule pattern:
And set it to forward to:
Then if someone entered:
They would be redirected to:
Here is the page rule pattern to use in Cloudflare so that the information after the .com is kept:
Set the URL Matches field to the old domain and add a * before the domain and /* after the domain name:
Then select the settings Forwarding URL and 301 – Permanent Redirect and input the new URL in the field below and add /$2 to the forwarded URL:
Save the rule. Now if someone visits:
They will be redirected to:
If you are permanently changing your domain name, set the following DNS records:
Change or create an A record with name: @ and the ipv4 value to 192.0.2.1 which is a dead end so that search engines better detect the 301 Redirect.
Change or create a second A record with name: www and the ipv4 value to 192.0.2.1 as well.
This will help you keep your customers happy, help with SEO and make the domain change seamless.
If you use Google Search Console, you can then tell Google about the domain switch via Search Console settings to help with SEO.