If you want to change the URL of your existing WordPress site – for example from a development environment “dev.mydomain.com” to “www.mynewdomain.com”, then the following steps are necessary:

  1. Modify WP_HOME and WP_SITEURL
  2. Update permalinks
  3. Search and replace old URL in the database


First of all, the new domain must be stored in WordPress. This can actually be found in the dashboard under Settings -> General.

wp home wp siteurl

If you change the URL there, then of course an error is displayed when saving, because the page is then no longer accessible under the old domain. So you have to log in to the dashboard again with the new domain.

If this does not work, then you can manually change the two fields in the database. You can find the two values under wp_options.

Another way is to insert two lines in the wp-config .php that override the entry.

To do this, simply download the wp-config .php file via FTP, open it and add the following two lines below:

define( 'WP_HOME', 'https://www.mynewdomain.com' );
define( 'WP_SITEURL', 'https://www.mynewdomain.com' );

Of course, your new URL should be entered instead of www.mynewdomain.com .

Upload the wp-config .php again and you can log into the dashboard with your new domain.

2. Update Permalinks

To make sure that also the links e.g. in the menus are rewritten correctly, you have to go to the settings -> permalinks once in the dashboard and save the settings there again (you don’t have to make any changes on this page, just click on “Save” at the bottom).

3. Search and replace old URL in the database

If you have access to your data-base (f. e. through MySql) you can search and replace the url there.

However, a somewhat easier and faster way is to use a plugin for this. I like to use the Better Search Replace plugin (but there are also many other plugins that can do the same thing).

better search replace

After installing and activating the plugin, it is self-explanatory. You enter the old domain that you want to search for, as well as the new domain that will be used. Then select all tables and at the bottom is a checkbox with which you can perform a test run for the time being. The entered URL will be searched for, but nothing will be changed yet. If the test run was successful, you can check the checkbox away and perform the process again without the checkbox, so that the URLs are changed immediately.

That’s it! Now click through the page again and check for broken links, but basically these are the 3 steps to change the URL of your WordPress page.

Photo by Fikret tozak on Unsplash

Write A Comment