I have setup wordpress on my server, and after some time I've changed the domain name of the installation. However, all of the old urls within the site point to the old domain. How can I change old urls to match the new domain without breaking the database?

Here's what I did: I went to settings -> general I've changed the site url and wordpress address (url).

The directory in which the wordpress installation is residing stayed the same.

How do I change all the old link? I was recommended using the UpdraftPlus migration feature, but I don't see how would this affect the old links. I'd use wp search-replace i.e. wp cli, but I'm not sure if that tool will change all GUIDs (I've read that GUID should not be changed, but I'm not sure if I need to).

For future visitors: I've resolved the issue using wp-cli:

wp search-replace 'example.net' 'example.com' --skip-columns=guid

Use --dry-run for the sake of your sanity.


3 Answers 3


Two possible easy ways to replace Old website URL to New Website URL:

1/ Directly replace in SQL file: Export the database and open SQL file. Manually find and replace old website URL with new website URL. Once replace is done, save and import database again.

2/ Use Migrate DB plugin: Use the third-party WordPress plugin 'WP Migrate DB' and find & replace both website URL and file path as shown in below screenshot. You can also replace other website data like admin email using this plugin.


enter image description here

  • I decided not to edit the SQL export manually, because of the trouble or replacing the serialized data. Last time I did that, I broke the site. I just have a one question for the neat Migrate DB plugin, do I need to replace GUIDs?
    – Gitnik
    Commented Sep 5, 2018 at 17:45
  • 1
    As per my knowledge, changing GUID is not recommended as GUIDs is a unique identifier of post content. So if you change GUIDs, all feed-readers will consider all posts content as new content and display all posts again. Also, it is not recommended to change GUIDs unless you change the location of files. Please have a look at below reference link: codex.wordpress.org/Changing_The_Site_URL#Important_GUID_Note Commented Sep 5, 2018 at 17:52
  • Thanks. the WP Migrate DB suggests changing the GUIDs if the site hasn't been live before, and since I'm not using it as a blog, but as a web presentation of a company, I don't see why I'd preserve the GUIDs. However, if the codex does not recommend changing them, it's probably best to leave them alone? deliciousbrains.com/wordpress-post-guids-sometimes-update
    – Gitnik
    Commented Sep 5, 2018 at 17:56
  • I do agree...If a website is not live then you can change GUIDs. Also, if you are not using it for a blog or articles then you can change. Commented Sep 5, 2018 at 18:02

You could use CLI. No reason to have any references to the old domain.

Another option I recommend is using Search & Replace DB, a free tool by Interconnect, to replace any instances of the host name in the database. It will handle setting the serialized data correctly for you.

First make sure that your wp-config is for the right database.

You need to go into your new database and change the site url and home url to the new address. I suggest NOT doing this through phpmyadmin though as it will cause some problems.

Go get this tool: https://interconnectit.com/products/search-and-replace-for-wordpress-databases/

Upload it into your www/ folder. (I usually rename the search and replace folder to SRDB.)

now navigate to your site with the SRDB at the end. (www.example.com/SRDB)and the top two lines you'll see a search field and a replace field. (if you get a db connection error here, double check the wp-config to ensure that it has the right credentials).

In the search place your old site address.

in the replace field place your new url.

hit live live run.

ONLY do this after ensuring you're on your new url and that SRDB is loaded into your new database.

Remove the SRDB folder when you are done.

  • Will WP CLI deal with the serialized data correctly too?
    – Gitnik
    Commented Sep 5, 2018 at 17:25
  • 1
    yes it will. :)
    – rudtek
    Commented Sep 6, 2018 at 18:22

The plugin I use to change URLs in the WP database is "Better Search and Replace" - has worked for me each time, and is easy to use. https://wordpress.org/plugins/better-search-replace/

You can do it manually in phpMyAdmin or the CLI, but that can be more difficult to do right.

Backup your database first, though, no matter which method you use.

  • Should I change the GUID-s or keep them? I'm not really a wp admin, but a sys admin, and since I'm just moving the domain as the site is about to go live, I'm not sure whether I should keep or change GUID-s.
    – Gitnik
    Commented Sep 5, 2018 at 17:39
  • 1
    The plugin I mentioned is just a search/replace for URLs (or any text) in the WP database. I don't have any experience using the Migrate DB process to move a site. I've developed my own 'move' process, which I detail (mostly for myself, but you are welcome to look at my process) here: securitydawg.com/moving-a-wordpress-site Commented Sep 5, 2018 at 17:59
  • Bonus points for documenting your process +1. I've decided to keep the GUIDs, as per the recommendation of the WordPress Codex.
    – Gitnik
    Commented Sep 5, 2018 at 18:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.