If you have been on this site before, you may have noticed a name change. Before today, this site had a domain name websiteforstudents.com. If you look at your browser address box, you will see geekrewind.com. A redirect is in place to send all web traffic from websiteforstudents.com to geekrewind.com. I’m going to show you how I did it in just under an hour. If you have a website or blog built in WordPress, and you have full access to your server’s console either via SSH or direct connection, then the step below will show you how to switch a domain or rebrand a website when using WordPress.

Changing a domain name in WordPress

As mentioned above, users can change or rebrand their websites hosted with WordPress easily, and the steps below describe the process.

Register a new domain name

Before migrating to a new domain, you’ll first want to register a domain name that you want to switch to. If you haven’t registered a domain name before, the post below shows you how to do that. How to register a domain name Once you have registered the domain name, make sure to point the name to the same server host IP as your current website.

Create a new virtual host or server block

Once the name is registered a DNS is updated to point to the same host (A record) IP, go and create a new virtual host when using Apache or server block if using Nginx. If you haven’t created a virtual host or server block, below is how to do it.

How to create a virtual host with Apache How to create a server block with Nginx

Now each environment will be different. 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: I have three server blocks. The first one is simply redirecting HTTP to HTTPS. The second block is redirecting WWW to the new non-WWW domain. The last block is redirect non-WWW to the new non-WWW domain. Blocks with listen 443 and http2 definitions have Let’s Encrypt SSL certificate configurations for both 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 that is referenced in the current server block, make sure to replace all current domain names with new domain names in the current server block file.

Update WordPress database

After creating a new server block and updating the current with a new domain name, go and update WordPress database tables and replace the current URLs with a new one. Sign on to your MySQL server. Type a password or simply press Enter to log on. There, change to your WordPress database. Next, run the commands below to view the current URLs. That will display lines similar to the one below: Next, run the commands below to update the values for the home and site tables. Next, run the commands below to update the post_content value in the wp_posts table: Next, run the commands below to update the meta_value value in the wp_postmeta table: Exit the database console.

Double-check your work

Once the changes above have been made, double-check your work to make sure you’re not missing anything. If all is working, restart Nginx or Apache and hope that all is well. That should do it! Conclusion: This post showed you how to rebrand or migrate to a new domain in WordPress. If you find any error above or have something to share, please use the comment form below.