How to Rebrand (or Change Domain Name) in WordPress
You can rebrand or change your WordPress website’s domain name by updating its core settings and ensuring proper redirection.
Changing a domain name involves telling WordPress and your server about the new address, making sure visitors and search engines find your site at the new location.
This is essential for a smooth transition when your brand evolves or you secure a better web address. I recently managed this for GeekRewind.com, switching its domain in less than sixty minutes.
You can perform this domain change yourself if you have full server access, such as through SSH or a direct file manager connection.
Change your WordPress domain by registering a new domain, pointing it to your host, creating a new server block or virtual host, updating your WordPress database with the new URL, and ensuring proper redirects.
Changing a domain name in WordPress
As mentioned above, users can easily change or rebrand their websites hosted with WordPress, and the steps below describe the process.
Register a new domain name
First, you need to get the new web address you want for your WordPress site; this is called registering a domain name.
If you haven’t registered a domain name before, the post below shows you how.
Once you have registered the domain name, point the name to the same server host IP as your current website.
Create a new virtual host or server block
After registering your new domain name, you’ll need to set up a place on your web server for it, which is called a virtual host for Apache or a server block for Nginx.
If you haven’t created a virtual host or server block, below is how to do it.
Now, each environment will be different. For example, yours might have unique parameters and definitions.
I use Nginx here. My new server block looks similar to the one below. websitesforstudents.com will be redirected to the new domain geekrewind.com:
server {
listen 80;
listen [::]:80;
server_name geekrewind.com www.geekrewind.com;
return 301 https://$host$request_uri;
include snippets/well-known.conf;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name www.geekrewind.com;
return 301 https://geekrewind.com$request_uri;
include snippets/well-known.conf;
........................................
........................................
}
server {
listen 443 ssl http2;
listen [::]:443 ssl;
server_name geekrewind.com;
return 301 https://geekrewind.com$request_uri;
include snippets/well-known.conf;
.........................................
.........................................
}I have three server blocks. The first one is simply redirecting HTTP to HTTPS. The second block redirects WWW to the new non-WWW domain. Finally, the last block redirects non-WWW to the new non-WWW domain.
Blocks with listen 443 and http2 definitions have Let’s Encrypt SSL certificate configurations for new and old websites.
Below is how to request Let’s Encrypt SSL certificates
- How to request Let’s Encrypt SSL certificates with Nginx
- How to request Let’s Encrypt SSL certificates with Apache
For the current website referenced in the current server block, replace all current domain names with new ones in the current server block file.
Update WordPress database
Now, you must update your WordPress site’s database to tell it about the new domain name, changing all the old web addresses to the new ones.
Sign on to your MySQL server.
sudo mysql -u root -p
Type a password or press Enter to log on.
There, change to your WordPress database.
use wpdatabse;
Next, run the commands below to view the current URLs.
SELECT option_name, option_value FROM wp_options WHERE option_name IN ('siteurl', 'home');That will display lines similar to the one below:
+-------------+------------------------------------+ | option_name | option_value | +-------------+------------------------------------+ | home | https://geekrewind.com | | siteurl | https://websiteforstudeents.com | +-------------+------------------------------------+ 2 rows in set (0.00 sec)
Next, run the commands below to update the values for the home and site tables.
UPDATE wp_posts SET guid = replace(guid, 'https://geekrewind.com','https://geekrewind.com');
Next, run the commands below to update the post_content value in the wp_posts table:
UPDATE wp_posts SET post_content = replace(post_content, 'https://geekrewind.com', 'https://geekrewind.com');
Next, run the commands below to update the meta_value value in the wp_postmeta table:
UPDATE wp_postmeta SET meta_value = replace(meta_value, 'https://geekrewind.com', 'https://geekrewind.com');
Exit the database console.
Double-check your work
After making all the changes to move your WordPress site to a new domain, it’s important to double-check everything to make sure it’s working correctly.
If everything is working, restart Nginx or Apache. I hope all is well.
That should do it!
Conclusion:
- Changing a domain name in WordPress involves several crucial steps to ensure a smooth transition.
- Register a new domain name and update DNS records to the current server host IP.
- If applicable, create a new virtual host or server block to handle the new domain and ensure SSL certificate configurations.
- Update the WordPress database to replace all instances of the old domain with the new one.
- Double-check all changes made and restart the server to ensure proper functionality.
Was this guide helpful?
About the Author
Richard
Tech Writer, IT Professional
Richard, a writer for Geek Rewind, is a tech enthusiast who loves breaking down complex IT topics into simple, easy-to-understand ideas. With years of hands-on experience in system administration and enterprise IT operations, he’s developed a knack for offering practical tips and solutions. Richard aims to make technology more accessible and actionable. He's deeply committed to the Geek Rewind community, always ready to answer questions and engage in discussions.
No comments yet — be the first to share your thoughts!