Halloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan NowHalloween DealsAmazon USOctober picks are moving - compare before checkoutAmazon US: current deals, useful picks and tech finds.See Picks×
FREEDOM251

Freedom251 › Blog › domain change

How to Clone a WordPress Site Without Broken Domain Links

By Freedom251 Team · · 10 min read

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The reliable way to clone WordPress is to move both the complete file set and the database, then perform a serialization-safe URL replacement on the copy. Changing only home or siteurl leaves old addresses inside posts, widgets, theme settings, plugin data and serialized options. That is why images, layouts and links often fail after an otherwise successful move.

Work from a backup, keep the destination private, preview the replacement with WP-CLI, flush rewrites and caches, and test the clone before changing DNS. The sequence below covers a staging copy, a move to a new domain and a move to a different path such as /blog.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What a complete WordPress clone includes

A clone is usable only when it contains the same application files and database state as the source. Exporting posts alone, or copying only the web directory, produces an incomplete site.

  • WordPress core and configuration: the document-root files, including wp-config.php and server rules where appropriate.
  • wp-content: uploads, active and inactive themes, plugins, language files and any custom code.
  • The database: posts, pages, users, options, menus, widget settings, plugin data, theme customizer values and other content.
  • Infrastructure dependencies: the destination database, PHP/runtime settings, scheduled jobs, DNS, CDN rules, mail delivery and third-party callbacks must be reviewed separately.

WordPress’s Developer Handbook warns that a domain or URL change creates additional concerns because old addresses can remain throughout the database. A file copy does not rewrite those values.

#1 Best Overall
Sale
TOZO A1 Wireless Earbuds Bluetooth 5.3 Light Weight in Ear Headphones | IPX5 Waterproof,2 Mics for AI Calls,Immersive Premium Sound Bass Headset with Charging Case,32 EQ via App Black
  • [Ultra-Lightweight Ear Buds Designed for Small Ears] Each earbud weighs only 3.7g and features a compact, ergonomic in-ear design made especially for small ears. Secure, low-profile, and comfortable for workouts, all-day wear or overnight sleeping.The ultra-slim profile sits flush in your ear with no hard edges poking or rubbing, so you can even sleep on your side without discomfort.
  • [Immersive Stereo Sound with TOZO OrigX Technology] TOZO OrigX tuning delivers clear vocals, balanced mids, and natural stereo sound for music, podcasts, and videos.
  • [Long Battery Life for Daily Use] Get up to 7 hours of playtime on a single charge, with up to 32 hours total using the charging case—ideal for workdays, commuting, and extended listening sessions.
  • [Bluetooth 5.3 & Stable Connection] Bluetooth 5.3 provides fast pairing, stable wireless performance, and reduced dropouts as you move around home or office.
  • [Deep Bass with Clear Vocals] High-performance drivers produce punchy bass while keeping vocals clean and detailed for everyday listening.

Plan the move before touching the source

Choose a maintenance window and record versions

Pick a period when content changes are minimal. Record the WordPress version, PHP version, active theme, plugins, multisite status and any unusual server or CDN settings. This inventory gives you a comparison point if the destination behaves differently and identifies extensions that need separate configuration.

Decide whether the clone is private

A staging copy should normally require authentication or an equivalent access control. Discouraging indexing in WordPress is useful, but a robots directive is not a security boundary: crawlers and people can still reach a public URL. Keep the clone inaccessible while you replace URLs and test it, and plan when indexing will be enabled after launch.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Freeze writes long enough to get a consistent backup

Pause publishing, form submissions and automated imports during the export. If the source keeps changing while files and the database are copied, the two parts can represent different moments. Note the exact backup time so you know what content is included.

Back up the source files and database

WordPress’s migration guidance calls for a backup of the WordPress directory, images, plugins, other files and the database before a move. Keep the original backup outside the destination and verify that it can be read before proceeding.

Export with WP-CLI

From the source site’s WordPress directory, export the database:

wp db export backup.sql

Copy the complete site directory, including wp-content/uploads, themes, plugins and any custom files. Do not rely on a browser download of the media library alone; the database contains the attachment records and relationships that make those files appear in WordPress.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Record what is not in the database

List DNS records, web-server redirects, CDN configuration, cron jobs, mail forms, analytics settings and third-party webhooks. They are outside the normal WordPress tables and will not be fixed by a database search-and-replace.

Build an isolated destination

Create the hosting and database environment

Create the destination hosting account, database, database user and document root. Match the source’s PHP and WordPress requirements before importing content. Copy the files to the destination and set file ownership and permissions appropriate to that host.

Import the database

Upload the SQL export and import it from the destination WordPress directory:

Rank #2
Sale
Smart Watch for Men Women Compatible with iPhone Samsung Android Phone 1.69 inch Full Touch Screen IP68 Waterproof Bluetooh Fitness Tracker Heart Rate/Sleep Monitor (Black)
  • 【IP68 Waterproof Multifunctinal Smart Watch】Torjalph fitness activity tracker smart watch is IP68 waterproof technology ,you can wear it when swimming,handwashing,it's rain-proof which means that you perform multiple exercise modes outside without worrying about sweat or rain corroding your fitness smart watch,and this watch equipped with a 230 mAh large capacity battery magnetic charging ,and this sports activity tracker watch can be used 5-7 days If fully charged.
  • 【Larger 1.83'' Full Screen Watch & Multi-dial Selection】1.83 inch full HD color touch screen smart watch for men / women provides excellent 240*284 resolution image quality ,This Bluetooth smart watch offers a better touch experience and remarkable immersion and ,more than 200 watch faces for you to choose from App"Da Fit ", you can change the dial style according to your mood to wear keeping the world on your wrist
  • 【Accurate Activity Tracker Smart Watch 】sports watch activity tracker uses sweat and dust resistant breathable silicone strap, our Fitness Tracker Smart Watch for Android iOS Phones supports 12 sports modes,walking,running,bicycle,swimming,badminton,basketball,football,rope skipping. This bluetooth calls smart watch for men women is lightweight and stylish, bringing more convenient and relaxing sports experience while also providing more protection.
  • 【Your 24 Hour Personal Daily Health Monitor】Fitness watch for women men full touch screen IP67 waterproof bluetooth smartwatch for Android iOS Phones with heart rate blood pressure monitor multifunction Andriod smart watch with steps counter sleep monitor sports fitness watch, monitoring blood oxygen saturation allows you to understand your physical condition in real time to track fitness progress ,to know your health status in time.
  • 【More Functions Bluetooth Call Smart Watch】This fitness activity smart watch full screen for iPhone and Android phones includes a bunch of new features including:The bluetooth smart watch can hang up the phone, receive and display WhatsAPP /Text /Facebook /Twitter /Messenger reminder.Support sedentary reminder, alarm clock, stopwatch, timer,weather information,music control, remote camera control compatible with Android 5.0 and above or iOS 9.0 and above smartphones.
wp db import backup.sql

Do not point the production domain at this environment yet. Use a temporary hostname or protected staging address while you work.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Prevent accidental mail and indexing

Staging can send password resets, form notifications or transactional mail to real recipients if it inherits production settings. Disable or redirect outbound mail until testing is complete. Keep HTTP authentication, an IP restriction or another access control in place, and use the site’s reading settings to discourage search engines as a second precaution.

Set the destination URL values

WordPress stores its primary addresses in the home and siteurl rows of wp_options. When the domain or path changes, set both to the destination address so WordPress can load its front end and administration correctly.

Change the options with WP-CLI

Run these commands from the destination directory, replacing the example address with the exact scheme, host and path you will use:

wp option update home 'https://new.example'
wp option update siteurl 'https://new.example'

For a subdirectory, include it in both values, for example https://new.example/blog. Keep the trailing-slash convention consistent with the source and destination. If WP_HOME or WP_SITEURL is defined in wp-config.php, those constants can override database values; update the configuration deliberately rather than changing the database and assuming the constants no longer apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Why changing only these rows is insufficient

The options tell WordPress where it lives, but old URLs can still be embedded in post content, widgets, menus, theme settings, plugin tables and custom fields. A page may therefore load while its images, stylesheets or internal links still request the old host. A database-wide, serialization-aware replacement on the copied database is the normal next step.

Replace old URLs safely with WP-CLI

Preview the replacement first

From the destination WordPress directory, run a dry run:

wp search-replace 'https://old.example' 'https://new.example' --all-tables --dry-run

The WP-CLI command searches and replaces strings in database tables and reports how many rows and values would change without writing them. Review the report for unexpected tables, an incorrect old address or a replacement count that is implausibly low or high.

Run the approved replacement

After checking the dry-run output, run the same command without --dry-run:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
New Bee Guitar Cable 10ft Electric Instrument Bass AMP Cord
  • [Low Noise High Fidelity] New bee guitar cord with 22AWG oxygen-free-copper center conductors provides enhanced signal transfer, the PVC insulation material and the high-density stranded copper double shield provide noise rejection for quiet operation
  • [Ideal for Choice] New bee 1/4 straight and right angle metal connectors, ensures a secure connection in any instrument, pedal, or amp jack. L shape great fro on stage guitar stands
  • [Wide Compatible] Suitable for mixer, power amplifier, microphone, effector, decoder, equalizer, electoronic organ, electric guitar, electric bass and other electronic equipments. Widely used in the installation of smart home, karaoke speaker, professional stage audio, etc
  • [Easy Disassemble] Making incidental repairs quick and easy! Very nice, flexible cable
  • [Dont Hesite to Order] 24 hours customer services and professional technology team are standing by
wp search-replace 'https://old.example' 'https://new.example' --all-tables

WP-CLI intelligently handles PHP serialized data. That matters because serialized arrays store string lengths; a plain SQL text edit can leave those lengths wrong when the new URL has a different number of characters, causing settings to disappear or errors when PHP unserializes the value.

Preserve GUIDs unless you have a specific reason not to

WordPress post GUIDs are identifiers, not ordinary display URLs. WP-CLI documents skipping the guid column during a normal domain move:

wp search-replace 'https://old.example' 'https://new.example' --all-tables --skip-columns=guid

Use that option when you are changing the public address but do not intend to redefine the identity of existing posts. If your migration has a deliberate GUID policy, document it before running the replacement rather than changing the column casually.

Handle multisite deliberately

In a multisite installation, first identify whether you are moving one site or the entire network. Target the correct site URL and tables. Use WP-CLI’s documented network mode only when the whole network should change; applying a network-wide replacement to a single-site move can alter other sites. Treat domain-mapping tables and network settings as a separate review item.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Account for protocol and path variants

If the old site has both HTTP and HTTPS references, or existed at more than one path, inspect the dry-run results for each form. Replace the exact forms that are genuinely obsolete. Do not perform a broad replacement that could alter an unrelated hostname containing the same text. If you are moving from a subdirectory to the root, include the path in the old value and test links that previously contained that directory.

Refresh rewrites and caches

After the database replacement, regenerate rewrite rules and clear object caches from the destination directory:

wp rewrite flush
wp cache flush

Flushing rewrites updates the rules used for pretty permalinks. Clearing the WordPress object cache removes values that may still contain the old address. Also purge any host-level, CDN or page-cache layer that is outside WordPress; those caches have their own controls and are not cleared by wp cache flush.

Validate the private clone before DNS changes

Crawl the clone while it remains protected. Test representative content rather than only the home page, and compare the results with the source.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Area What to test Typical symptom of a missed reference
Front end Home page, several recent posts, older posts, pages, category archives and tag archives 404 responses, redirects to the old host or links that still contain the old path
Media Featured images, inline images, PDFs and other uploads from different dates Broken images, downloads from the old domain or mixed-content warnings
Theme and assets Desktop and mobile layouts, CSS, JavaScript, fonts and customizer settings Unstyled pages, missing scripts, wrong colors or a theme panel that appears reset
Navigation Menus, breadcrumbs, pagination, search results and internal links Loops, links to the source site or incorrect subdirectory paths
Accounts Administrator login, a normal user login, logout, password reset and capability checks Login loops, cookies scoped to the wrong host or reset links sent to the source
Forms Contact, comment, newsletter and upload forms; verify delivery in a safe mailbox Submission errors, mail sent to production or callbacks aimed at the old endpoint
Search and SEO Canonical tags, XML sitemaps, pagination, robots behavior and any noindex control Canonical URLs point to the old host, a staging copy is crawlable or sitemaps list obsolete URLs
HTTP behavior HTTPS, redirect chains, trailing slashes and common old URLs Mixed content, loops, too many redirects or inconsistent slash handling

Check for old addresses directly

Search the rendered HTML, browser developer tools and server logs for the old hostname. Inspect CSS and JavaScript responses as well as page markup; a URL can be hard-coded in an asset or a theme file and never appear in post content. Compare a sample of source and clone URLs for 404s and unexpected redirects.

Rank #4
BSIMB 15.6" Digital Family Calendar & Chore Chart, No Subscription Fees
  • Digital Family Calendar: BSIMB digital calendar wall touch screen puts an end to your chaotic life. Designed for busy families, the digital calendar keeps you organised and in step with your family. Assign different colours and tasks to each family member to make family scheduling easier and more intuitive.
  • Easy Setup and Auto-Sync: Plug in, connect to WLAN and auto-syn your electric calendar in minutes. Digital wall calendar compatible with Google calendar, iCloud calendar, Outlook calendar, Cozi calendar and Yahoo calendar. Add events directly on the device or through the ecalendar app. Electronic calendar stays current whether you're at work or traveling—no manual updates needed.
  • All-In-One Home Assistant: Smart calendar builds habits and encourage independence with personalised chores. Display daily meal plan to reduce the daily ‘What's for dinner?’ stress. To-do lists keep track of everything you want. Turning chores into valuable achievements with stars and rewards, making life easier and more enjoyable.
  • Manage Anytime Anywhere: BSIMB electronic calendar for family stay connected with the powerful ecalendar app. Access and manage your digital wall calendar anytime, anywhere with free features like stars & rewards, photo screensaver, chore charts, meals plans, to-do lists etc. Electronic planner paid features like Magic Import tailor advanced tools for users with special needs.
  • Stay in Touch with Loved Ones: Share photos or videos from your phone to electronic wall calendar with app, instantly update your life moment, and keep in touch with your family, especially those who are far away; you can also surprise your smart calendar digital wall by sending him a wish card; it's also great for keeping tech-illiterate elders in touch with the youngsters.

Review scheduled and external operations

Confirm that cron jobs, payment or form callbacks, analytics collection, CDN origins, DNS records and web-server redirects reference the correct environment. These integrations are not necessarily stored in WordPress tables, so a successful wp search-replace does not prove they were updated.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Cut over only after validation

Prepare DNS

When practical, lower the DNS TTL before the planned change so resolvers refresh the record sooner. Point the production domain to the validated destination only after the private crawl and functional tests pass.

Keep the source available

Do not immediately delete or overwrite the old site. Keep the pre-migration backup and, where feasible, the old environment available while DNS propagates. Watch access and error logs for normal traffic, unexpected requests to the old host, 404s and redirect loops.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Re-crawl after propagation

Test the public domain from more than one network after DNS changes. Recheck canonical tags, sitemaps, forms and login because a proxy, CDN or production-only rule can behave differently from the staging hostname. Turn indexing controls back on at the intended launch point and remove temporary access restrictions only when the site is ready for public traffic.

Common failure modes and their fixes

Only siteurl was changed

Symptom: WordPress opens at the new address, but content links, images or plugin settings still point to the old one.

Fix: Set both home and siteurl, then run a database-wide, serialization-aware replacement on the copy. Check for constants in wp-config.php that override the database.

SQL was edited with a plain text tool

Symptom: Theme or plugin options vanish, widgets reset or PHP reports unserialization errors.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Fix: Restore the untouched backup and repeat the operation with WP-CLI or another tool that understands PHP serialization. Do not try to repair altered serialized strings by hand unless you fully understand the data structure.

Rewrites or caches were left stale

Symptom: A replacement report looks correct, but pretty URLs return 404s or visitors see old content.

Fix: Run wp rewrite flush and wp cache flush, then purge external page and CDN caches and retest in a fresh browser session.

The staging copy was indexable

Symptom: Search engines discover duplicate pages or users arrive at a pre-launch hostname.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Fix: Protect staging with authentication or equivalent access control, discourage indexing, remove public links and inspect robots and sitemap output before launch. If the clone was already indexed, handle the resulting URLs deliberately rather than assuming a robots change erases them immediately.

Non-WordPress references were missed

Symptom: WordPress pages work, but webhooks, scheduled jobs, mail, analytics or CDN delivery fail.

Fix: Use the infrastructure inventory made before the move. Update DNS, server redirects, cron commands, mail settings, analytics properties, CDN origins and third-party callback URLs independently, then exercise each integration.

The wrong tables were replaced

Symptom: A multisite neighbor changes unexpectedly, or the replacement count includes data belonging to another environment.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Fix: Restore the backup, identify the intended site and table scope, and use the appropriate WP-CLI table or network controls. A dry run should always precede the write operation.

Rollback plan

Rollback is simplest when the original site remains untouched and the backup is retained. If validation fails, stop the cutover, keep DNS pointed at the source, and correct the destination. If the new site is already public and must be withdrawn, repoint DNS to the source, restore any changed external records, and preserve logs from the failed attempt. Do not import a destination database over the source merely to reverse a URL replacement; that can overwrite legitimate content added after the clone was created.

A repeatable migration checklist

  1. Schedule a quiet window and record WordPress, PHP, theme and plugin versions.
  2. Freeze writes, export the database and copy the complete WordPress directory.
  3. Inventory DNS, redirects, CDN, cron, mail, analytics and webhook dependencies.
  4. Create a protected destination with its own database and document root.
  5. Copy files and import the SQL dump with wp db import backup.sql.
  6. Set destination home and siteurl values, accounting for any configuration constants.
  7. Run wp search-replace with --dry-run, inspect the report and confirm the scope.
  8. Run the approved serialization-safe replacement, normally preserving guid.
  9. Flush rewrites and object cache, then purge external caches.
  10. Crawl pages, media, assets, forms, accounts, redirects, canonicals, sitemaps and robots behavior.
  11. Update non-WordPress services, lower or confirm DNS TTL, and cut over only after tests pass.
  12. Monitor logs after propagation, retain the backup and remove staging restrictions only when launch is intentional.

Bottom line

A broken-link-free clone is a controlled data migration, not a file copy. Move the files and database together, change the destination URL settings, use WP-CLI’s dry-run and serialization-aware replacement, refresh rewrite and cache state, and prove the clone works while it is private. Only then should DNS and indexing change.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

domain changesite migrationstagingwebsite backupsWordPressWP-CLI

Leave a Reply

Your email address will not be published. Required fields are marked *

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.