program using: ubuntu 18.04

Problem: so i have two local wordpress sites running on my localhost, say site1.com and site2.com

I have migrated all of the databases from site1.com to site2.com. Now when I click on one of the link that's in site2.com, it's changing the URl to site1.com/pageIwantTovisit. I don't want that. I want it so that, if I'm on site2.com, then all the links should refer to site2.com/pageIwantToVisit.

I'm using phpmyadmin. I've changed the home and siteURL to site2.com but the links don't change unless i manually hardcode all the link which will take forever.

The link in site2.com should go from about page to blog page. Thank you.

  • Use this script to replace ALL urls in your database. Mar 6, 2019 at 18:46
  • hey, I'm already using search and replace plugin from wordpress. Mar 6, 2019 at 18:53
  • Clear browser cache Mar 6, 2019 at 18:56

1 Answer 1


When editing content in the content editor WordPress hardcodes the current URL that is being used to access the WordPress admin. This is usually found in link href and image src. There are several plugins or tools (like wp-cli) that can assist you in finding and replacing the url between environments.

You will likely want to your search to look something like:

Old //site1.com

New //site2.com

NO TRAILING SLASH in the search! Don't use the protocol if you are not trying to switch/normalize urls from http to https, same goes for www domain variants.

If you access the site at several different domains during the development cycle you may want to look into tools like the WordPress plugin WP Migrate DB Pro that find and replace while migrating between environments or manually on the current environment.

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.