My 10-step process for changing your website domain name.
DISCLAIMER: if you’re trying to learn how to do this yourself for a really important site, please don’t! Hire a developer. It might take them a good 2-4 hours and they might even notice other little issues that you don’t. Please don’t try screw around if you don’t have experience here. I see people mess around and try to DIY, then jack up their SEO rankings that they’ve built up over the years. Don’t be an idiot!
STEP 1 – decide on domain name
Are you sure? ARE YOU REALLY SURE? Cuz it’s a pain in the ass to recover from one change…and even more so if you do multiple changes in such a short time. Not only more work to do, but also more chances to screw up.
What structure?
- Please tell me it’s gonna be https://yourdomain.com (no “www” in front as that’s outdated now).
- Are you changing it to something like “theredsquirrel.com”? Cuz what if customers type only “redsquirrel.com”? Getting “redsquirrel.co” ain’t gonna help you too much there either.
Anyway, this isn’t supposed to be a domain name picking lesson. Just think your decision through several times!
STEP 2 – add new domain to your webhosting
- If you’re using cPanel, it’s a matter of adding it to “Addon domain”.
- If you’re using another interface, follow their guide for adding new domains/sites to your account.
- Don’t forget to generate SSL for new domain.
This is all assuming you’re keeping the same webserver and webhosting account, right?
STEP 3 – migrate website to new domain name
Usually when you add a new domain, it creates a new directory for you to place your website files.
- Copy (or move) your files to the new directory.
As for database, you have some options:
- Use existing database (maybe rename it if you need) if your webhosting account allows all websites to access all database…like cPanel.
- Create new database (exporting from old, import into new) if your webhosting has isolated accounts for each website. In which case you have to create new database AND database user.
- If you had to create a new database/user then update the database credentials in your wp-config file.
This step is basically like migrating a website to a new webserver, but instead you’re just migrating it to a new domain name.
STEP 4 – change site URL in WordPress settings and database
When you first try to load your website from the new domain, it’ll probably keep redirecting to the old domain (which is normal). There are still several steps to do.
- Change WordPress/site address in WordPress settings – ideally, you’d logged into your site and change it from the backend. But until you get in, you either have to edit it from the wp_options table in database or specify site address/url in your wp-config.php file. (I prefer database route.)
STEP 5 – change site URL in database
Now you have to update all your strings in database so your site is looking for posts and images files from the correct URL. Easiest way is to install “Better Search Replace” and put old domain in FROM and new domain in TO.
- I highly recommend the format of “olddomain.com” and “newdomain.com”.
- Do not do just “olddomain” and “newdomain” as that may cause more trouble.
If for whatever reason your database is too big and search/replace doesn’t work, go get a developer and let them update manually from SQL queries in phpMyAdamin.
STEP 6 – update your htaccess
Make sure any references to your old domain are updated to the new one.
STEP 7 – update Google Search Console
Update your website settings in Google Search Console and also Google Analytics to use your new domain name!
STEP 8 – redirect old domain to new one
Ideally, this is most efficiently done from your domain registrar or DNS provider (if using Cloudflare) rather than from your web-server since that would use up your web server processing power. Make sure it’s a 301 permanent redirect for anything from old domain to new domain.
For redirecting from your webhost (with htaccess):
Redirect 301 / https://newurl.com/ <IfModule mod_rewrite.c> RewriteEngine On </IfModule> RewriteCond %{HTTP_HOST} ^oldurl\.com$ [OR] RewriteCond %{HTTP_HOST} ^www\.oldurl\.com$ RewriteRule ^(.*)$ "https\:\/\/newurl\.com\/$1" [R=301,L]
For redirecting from Cloudflare page rule:
- Create page rule, putting
*oldurl.com/*
for url match field - Pick “Forwarding URL” for setting. Choose “301 – Permanent Redirect” and
https://newurl.com/$2
for destination URL. (My example assumes you want the new url without “www”.)
STEP 9 – check for errors
- Check for broken links – there are free tools online and even downloadable desktop apps.
- Monitor your Google Search Console for any errors/404/etc.
- Monitor your Google Analytics for decreased traffic.
STEP 10 – enjoy life
Don’t forget to slap yourself for trying to do this alone instead of hiring a developer to handle for you.
Panos
Great tutorial, I am going to change my domain name tomorrow so I am going to follow your instructions. I have one question, not related to the article; how did you placed the “notify me of follow-up comments via e-mail” field? I couldn’t find a lightweight plugin to do that and I don’t really want to install Jetpack to do it. Any help will be much appreciated!
P.S. Waiting for your new videos!
Johnny
Hi Panos, let me know what videos you like. My comment reply plugin is Comment Reply Notification by denishua. It’s been abandoned for a long time but still works great. On some other sites of mine, I use a rewritten version of it…which I plan to release soon. Just make sure you pair it with an email plugin (and transactional email service) for best deliverability.
jujuwiwi
For a long time, I thought it was necessary to remove the www in front of the domain name as you indicate in brackets at the beginning of the article : “no “www” in front as that’s outdated now”.
However, now I put the www in front mainly for cookie management. Can I have your opinion on this? What do you think of this detailed article which recommends to do it too:
https://www.yes-www.org/why-use-www/
Thanks.
Johnny
I see the points. They are valid but can be mitigated and ultimately because I still prefer without WWW. This is a really great topic and one I will make a post about. Thank you for asking!
jujuwiwi
Me too “aesthetically”, I prefer without the www, but I also like the fact that these www are mostly a sub-domain with the advantages that go with it.
Moreover, we live in a world where the past is coming back in fashion. Why not these www for a website? With of course the modernization brought by https. I think it’s a good compromise between functionality, modernity and fashion. For me, aesthetics should never take priority over functionality.
Almost all the main web actors currently use www as canonical URL like google, facebook, amazon…
Johnny
There are many large sites not using WWW. Twitter is one of those. I don’t see it is aesthetics over functionality as when it comes to domain names, the aesthetic IS the functionality. But I have a long guide almost ready to release regarding this topic. It’s a good one.
jujuwiwi
If I’m not mistaken, Twitter needs another domain to serve static content.
I think with only one domain, it’s necessary to make canonical the www. version when you have other subdomains under the same domain, with their own security contexts.
For example, I find useful to have a sub-domain to develop a new version of the site without impacting the site in production.
On the other hand, I share the url without the www, because it’s more aesthetic and functional. Afterwards, the server performs the redirection.
Now I’ m a little confused. I’m looking forward to your guide, thanks!
Johnny
Here you go! To WWW or not to WWW
mato
Is this post out yet?