🔁
Hosting

Migrating a WordPress Site: Replacing URLs Without Breaking Serialized Data

15.11.2026
← All articles

Moving a WordPress site to another host or domain looks simple: copy the files, export the database, import it somewhere else. In practice the real trouble starts right after that. The site loads, but images are missing, menus disappear, Elementor pages render empty, or the admin login keeps bouncing you back to the old domain. Almost every time the cause is the same: old URLs in the database were replaced incorrectly, or not at all.

Why WordPress remembers the old address

WordPress stores its address in many places. The main ones are the siteurl and home rows in wp_options, but post content contains absolute image links, page builders keep their settings in wp_postmeta, and widgets and theme options live as separate rows in wp_options. Changing two values is not enough; the old domain is spread across the whole database.

Take a Tashkent flower delivery shop whose site was built on a staging address, gul-test.example.uz, and is now moving to misol.uz. The string https://gul-test.example.uz appears thousands of times: in product images, slider settings, the footer widget and even the form plugin's email template.

What serialization is and why plain find-and-replace breaks it

PHP stores arrays and objects in the database using serialize(), which writes the byte length in front of every string value. A widget setting might look like this:

a:1:{s:3:"url";s:31:"https://gul-test.example.uz/img";}

Here s:31 says the next string is exactly 31 bytes long. If you open the SQL dump in a text editor and swap the domain for the shorter https://misol.uz, the string changes length but s:31 does not. unserialize() then fails and WordPress silently ignores the setting, so widgets vanish, theme options reset and builder blocks go blank. You need a tool that unpacks the value, replaces the text, recalculates the length and packs it again.

Doing it right with WP-CLI

The most reliable option is WP-CLI's search-replace command, which handles serialized data correctly. With SSH access, go to the site folder, back up the database and do a dry run first:

cd ~/www/misol.uz
wp db export ../backup-oldin.sql
wp search-replace 'https://gul-test.example.uz' 'https://misol.uz' --all-tables --dry-run

--dry-run changes nothing and only reports how many replacements each table would get. If the numbers look sensible, run it for real, and cover the http:// and protocol-relative variants too:

wp search-replace 'https://gul-test.example.uz' 'https://misol.uz' --all-tables
wp search-replace 'http://gul-test.example.uz' 'https://misol.uz' --all-tables
wp search-replace '//gul-test.example.uz' '//misol.uz' --all-tables
wp cache flush

If the document root path changed between servers, some caching and security plugins may also need their stored absolute paths replaced the same way.

Without WP-CLI

Use a serialization-aware plugin such as Better Search Replace, which runs from the dashboard and has a dry-run mode. The Search Replace DB script is another common choice, but delete it from the server as soon as you finish, because it gives full database access to anyone who finds it. Never edit the dump with a text editor's "replace all".

Migration order

  1. Take a full backup of files and database on the old host.
  2. Upload the files to the new host, ideally as an archive extracted in the panel.
  3. Create an empty database and user, then import the dump.
  4. Put the new database name, user and password in wp-config.php.
  5. Replace the old URL with WP-CLI or a plugin.
  6. Re-save permalinks and clear all caches.
  7. Point DNS to the new server and issue an SSL certificate.

On sayt.uz hosting most of these steps happen in the ISPmanager panel: creating the database, extracting the archive in the file manager and enabling a Let's Encrypt certificate.

When the admin redirects to the old domain

If you cannot even log in before the replacement, add two temporary lines to wp-config.php. They override the database values; if you keep them, the address fields in the admin settings become locked.

define('WP_HOME', 'https://misol.uz');
define('WP_SITEURL', 'https://misol.uz');

Checks after the move

Search the page source for the old domain, and watch for mixed content warnings caused by images or scripts still loading over http://. To find leftovers in the database:

wp db search 'gul-test.example.uz' --all-tables

Then send a test message through the contact form, add a product to the cart and check the mobile layout. In the flower shop example, this is the step where you would notice the form plugin still signing emails with the staging domain.

Keep a fresh database copy before every change, and any mistake becomes a few minutes of rollback rather than a lost evening.

Related articles

🤖 Telegram bot "Conflict: terminated by other getUpdates" error: cause and fix 📊 Grafana and Prometheus: server monitoring basics 📬 Migrating Mailboxes with imapsync Without Losing a Single Email 🪶 Can you use SQLite in production?
🌐 Language
🇺🇿 O'zbek 🇺🇿 Ўзбек 🇷🇺 Русский 🇬🇧 English ✓