Skip to content
FunnelGuard

Fix guide by FunnelsGuard

WordPress redirecting to staging after migration: how to fix it

OPS-247High impactDetectedBy FunnelGuardPublished Updated
On this page

What this issue is

WordPress stores its own address in two settings: WordPress Address (URL), saved as siteurl, and Site Address (URL), saved as home. When you copy a staging site to live, or move a site to a new host, those values often come along unchanged. WordPress then sends visitors to the old staging address, such as staging.example.com.

How a staging redirect eats your funnel
  1. Ad or search clickVisitor opens www.example.com
  2. WordPress loadsReads siteurl/home from the database
  3. Redirect to stagingSent to staging.example.com
  4. Form or checkoutBlocked, password-protected or noindexed
  5. Lead or saleNever recorded

The visitor lands on the live domain but is sent to staging, so every later step is lost.

Why it costs you leads or sales

Visitors who reach staging usually hit a login wall, a broken page, a browser security warning or a site that does not process forms. Paid clicks are wasted, and analytics and ad pixels may be attached to the wrong domain or blocked there.

Daily leads before and after a bad migrationExample numbers
Daily leads before and after a bad migration (example)Before migration: 20 leads per day; Redirecting to staging: 1 leads per day; After fix: 20 leads per day081520120Before migrationRedirecting to stagingAfter fixleads per day

Example: illustrative numbers for a site that gets about 20 leads a day before the migration.

How to check if your site has it

Quick checks
  • Open your live URL in a private window and watch the address bar for a change of domain.
  • Go to Settings > General and read WordPress Address (URL) and Site Address (URL).
  • If those fields are greyed out, look for WP_HOME or WP_SITEURL in wp-config.php.
  • View page source on the live site and search for the staging domain.
  • Click your main menu, a form submit button and a checkout link and check where each one goes.
  • Test from a phone on mobile data, so you skip your own cached redirects.
See where a URL really redirectsbash
curl -sIL https://www.example.com/ | grep -i -E '^(HTTP|location)'

How to fix it

Set the correct URL
  1. Use Settings > General

    If you can still log in at wp-admin, set both WordPress Address (URL) and Site Address (URL) to your live address, including https, then save.

  2. Check for wp-config overrides

    If the fields are greyed out, open wp-config.php and edit or remove the WP_HOME and WP_SITEURL lines.

  3. Replace leftover links

    Use WP-CLI search-replace (see the code below) or a trusted search-replace plugin that handles serialized data. Do not run plain SQL find-and-replace on serialized values.

wp-config.php: force the live URLphp
define( 'WP_HOME', 'https://www.example.com' );
define( 'WP_SITEURL', 'https://www.example.com' );
WP-CLI: update options and replace old linksbash
wp option update home 'https://www.example.com'
wp option update siteurl 'https://www.example.com'
wp search-replace 'https://staging.example.com' 'https://www.example.com' --all-tables --dry-run
wp search-replace 'https://staging.example.com' 'https://www.example.com' --all-tables
wp cache flush
Fix it in order
  1. Back up files and database

    You need a way back if a replace goes wrong.

  2. Set home and siteurlWordPress

    Use Settings > General, wp-config.php or WP-CLI.

  3. Run a dry-run search-replace

    Check the number of matches, then run it for real. Repeat for the http and protocol-less versions of the staging URL if needed.

  4. Clear every cacheWordPress

    Clear the caching plugin, server cache, CDN and your browser. Also regenerate builder CSS files (Elementor: Tools > Regenerate CSS & Data).

  5. Remove stale redirects

    Check redirect plugins, .htaccess, host-level redirects and CDN rules for the staging domain.

  6. Review plugin settings

    Check SEO, form, email, payment and tracking plugins for saved staging URLs, webhook addresses and return URLs.

How to confirm it's fixed

Confirm on the live domain
  • curl -sIL shows no hop to the staging host.
  • The home page, a deep page and a blog post load without changing domain.
  • Page source contains no staging domain.
  • Submit a test lead through your main form and confirm it reaches the inbox and CRM.
  • Check in your ad and analytics tools that hits arrive for the live domain.
  • Open Google Search Console and request a recrawl if staging URLs were indexed.

How to prevent it happening again

Migration habits
  • Use a migration plugin or WP-CLI that rewrites URLs for you, and always run a dry run.
  • Keep a short go-live checklist: URLs, redirects, caches, forms, tracking, indexing settings.
  • Untick Settings > Reading > Discourage search engines on live, and tick it on staging.
  • Avoid pushing a staging database over live. Move only the changes you need.
  • Run a form and tracking test straight after every migration, not days later.

How FunnelGuard handles this

FunnelGuard detects this today. A robot visitor runs your real customer journeys on a schedule, such as a lead form or checkout. If your site sends it to a staging domain, the journey fails at that step. FunnelGuard re-checks the failure from a second region, then sends one alert by email, Slack, Teams, WhatsApp, webhook or PagerDuty, with a screenshot and a likely cause.

Questions people ask

Why does my WordPress site redirect to the staging site after migration?

The database still holds the staging address in the siteurl and home options, or wp-config.php sets WP_HOME and WP_SITEURL to it. WordPress reads those values and sends visitors there. Update them to your live URL and clear caches.

How do I change the WordPress Site URL if I can't log in?

Add WP_HOME and WP_SITEURL lines to wp-config.php with your live address. Or run wp option update home and wp option update siteurl with WP-CLI. You can also edit those two rows in the wp_options table.

Why are the Site URL fields greyed out in Settings > General?

WP_HOME or WP_SITEURL is defined in wp-config.php, which overrides the database and locks the fields. Edit or remove those lines to change the value.

How do I replace the staging URL across my whole WordPress database?

Use WP-CLI: wp search-replace 'https://staging.example.com' 'https://www.example.com' --all-tables, ideally with --dry-run first. It handles serialized data safely, unlike a plain SQL replace.

Why does my site still redirect to staging after I fixed the Site URL?

A cache or another rule is probably still sending the redirect. Check your caching plugin, CDN, host-level redirects, .htaccess and any redirect plugin, then test with curl or a private window.

Can a staging redirect hurt my SEO?

Yes, it can. Search engines may index staging pages or lose live ones if the redirect lasts. Fix it quickly, make sure staging is blocked from indexing, and recheck in Search Console.

How can I tell quickly if my forms still point to staging?

View the page source and search for the staging domain, especially in form action and script URLs. Then submit a real test lead on the live domain and confirm it arrives.

Does FunnelGuard catch this?

Detected

FunnelGuard checks for this today.

Stop finding out from your customers

FunnelGuard runs your real forms and checkouts on a schedule, checks the tracking and the leads behind them, and alerts you once, with a screenshot. Try any paid plan free for 3 days.