Problem Description
The following scenarios are a few possible reasons why you might have the wrong URL saved in your database (likely in multiple spots). 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 WordPress plugins to handle this functionality unless you're 100% certain they can do this job properly.
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 you have the correct old and new URLs before proceeding. Please also take a backup of your database.
- Login to the WordPress admin
- Go to Plugins > Add New
- Search for the "Update URLs" Plugin by "KaizenCoders" (formerly Velvet Blues)
- Go to Tools > Update URLs
- Enter your old URL under “Search for” and your new URL under “Replace with.”
- Check the "Content" button (and optionally attachments, if you know you need that too)
- Choose “Update URLs NOW”. This action is non-reversible.
Troubleshooting
If you have already imported an SQL file that has had its URLs or other data modified manually (or with some tools), and the site does not work as it should after import, this is because however the changes were completed the data format (serialized) was not taken into account. There are two ways to fix this:
- Start over and do so using our 1-click web apps to handle the clone or migration as we know it handles serialized data correctly, or
- If you have the SQL file still with your modifications, run this script on the file. It will update the character counts for all serialized data in your SQL file to the correct values. Then import the (now fixed) sql file again and you should be all set!