Problem Description
The following scenarios are a few possible reasons why you might have the wrong URL saved in your database. There may be more reasons not described here.
- Changed domain name
- Switched to use HTTPS from HTTP (or vice versa)
- Switched to either using or no longer using www as your primary URL
- Copied content from a staging site to your live URL
There are many issues that can be created by having the wrong URL for either the WordPress Site URL or various resources like photos stored in the database. Here's a few of them:
- You get mixed content warnings and/or some files fail to load (images, styles, etc)
- You have password protected a staging or development copy of the site, but after loading the live site, visitors are prompted for the username and password. This occurs because the live site is referencing files on the staging site, which now require authentication.
Note: using our 1-click web apps utility to Clone or Sync WordPress installations is the best way to avoid URL mismatches in the database. Please avoid using other tools like plugins for WordPress to handle this functionality.
Problem Resolution
No matter the specific scenario that got you here, as long as you know you have URL mismatches, the solution is to find and replace them in the database. To do this successfully you must know the complete old URL and new URL. Here are some examples:
- www change: old URL might be https://www.mydomain.com and the new URL would be https://mydomain.com
- https change: old URL might be http://mydomain.com and the new URL would be https://mydomain.com
- staging site change: old URL might be https://staging.mydomain.com and the new URL would be https://mydomain.com
Double and triple check that the old and new URLs are correct before proceeding.
- Login to the WordPress admin
- Go to Plugins > Add New, search for “Better Search Replace” by Delicious Brains and install and activate it.
- Go to Tools > Better Search Replace and enter your old URL under “Search for” and your new URL under “Replace with.” Select all tables and uncheck “Run as dry run” before clicking “Run Search/Replace.” Because this action is non-reversible, you may wish to keep the dry run option checked, then verify the results before then unchecking that option and running it again.