Lukasz Drazewski

personal blog

How to change the domain name of the Next.js + Wordpress website

Domain change - preparation

First of all, before the domain change operation, I thought carefully about what actions to take, step by step, to make everything go smoothly. In my case, I had to make a few changes. The first and most important step was to link the new domain to the current website that I run on Vercel.

Vercel - add new domain

Although you can purchase a domain with Vercel this time I have decided to add my domains purchased outside of Vercel to my current project. In the Domains section, I chose the add option. Then I selected my project and then entered my new domain name. My new domain has now appeared in the Domains section.

The whole procedure of adding a domain in Vercel is great described in technical documentation.

Due to the fact that my domain was purchased outside of Vercel I had to configure DNS settings at my domain provider pointing to Vercel's DNS (,

DNS propagation sometimes takes 24 hours or more, but in my case I was lucky because I noticed the changes after less than an hour. In the meantime, I took up the next steps.

Backend - change of domain for Wordpress

As I mentioned before, the website uses the Wordpress backend. As the instance of Wordpress available at the url: (of course this domain is completely different :) ) is located at the same hosting provider with which I have my domain registered, so now I had to add a redirect from Vercel. In the DNS Records section in the domain settings on Vercel, I had to add an A record named panel (an extension in front of my regular domain) and the IP address of the server on which Wordpress is placed.

In Wordpress itself, I also had to make two changes. The first change was to set new values for WP_HOME and WP_SITEURL. The easiest way to do this is in the wp-config.php file:

When I was able to log into the WP admin panel, I made one more global change of all entries in the database. All phrases containing the old domain name I replaced with new one. For this purpose, I used a great plugin: Better Search Replace.

Code changes

While DNS propagation continued, I took care of the last major change, and actually a number of minor changes to the application code itself. It often happens that somewhere in the code we have hardcoded URL values. So I had to review all the code for the presence of the old domain and replace it with the new one. It seems obvious, but it is worth remembering. After all these changes, the new version of the website was deployed.

301 redirect for old domain

After completing this work, and finishing drinking coffee, I noticed that my website is finally displayed under the new domain. Everything went smoothly and works as it should. But there is still … the old domain. I didn't want to delete it right away due to its presence in Google. If I removed the old domain, my website under the new domain would have to be indexed again, which of course I did not want, because in fact, entries from Google accounted for over 90% of all visits. So I had to add a redirection from the old domain to the new one - redirect 301 Moved Permanently. This redirection we can set in the settings of the old domain in Vercel.

Search Console - change for Google

The last change did not affect the website itself and its proper working, so I did not have to do it right away, but I wanted the new domain to replace the old domain in Google search results as soon as possible. For this, I had to go to the Search Console panel and add a new domain there. After adding domain, I chose "Change of Address" in the old domain settings and then indicated the new address. After confirming that I am the owner of the new domain, the domain change process for the pages indexed by Google has started. The process is quite slow, however, and currently, three weeks after the domain change, only 30% of indexed url addresses have changed the domain.

And that was it. The whole work took about 15 minutes, but I have to mention here that I... did it several times before this time :) So I knew perfectly well what steps I had to take, and I didn't even mind that the DNS propagation time was sometimes quite long. I hope that this short and quite specific guide will be useful to someone.