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.
- Ad or search clickVisitor opens www.example.com
- WordPress loadsReads siteurl/home from the database
- Redirect to stagingSent to staging.example.com
- Form or checkoutBlocked, password-protected or noindexed
- 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.
Example: illustrative numbers for a site that gets about 20 leads a day before the migration.
How to check if your site has it
- 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.
curl -sIL https://www.example.com/ | grep -i -E '^(HTTP|location)'How to fix it
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.
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.
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.
Fix the options in the database
If you cannot reach wp-admin, update the siteurl and home rows in the wp_options table (your table prefix may differ), or use WP-CLI.
Check server rules
Look in .htaccess or your nginx config for a hard-coded redirect to the staging host and remove it.
Check the CDN and host
Review redirect or page rules in your CDN and hosting panel for the old domain.
define( 'WP_HOME', 'https://www.example.com' );
define( 'WP_SITEURL', 'https://www.example.com' );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 flushBack up files and database
You need a way back if a replace goes wrong.
Set home and siteurlWordPress
Use Settings > General, wp-config.php or WP-CLI.
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.
Clear every cacheWordPress
Clear the caching plugin, server cache, CDN and your browser. Also regenerate builder CSS files (Elementor: Tools > Regenerate CSS & Data).
Remove stale redirects
Check redirect plugins, .htaccess, host-level redirects and CDN rules for the staging domain.
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
- 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
- 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.
Related issues
- OPS-246Permalink flush breaking URLs (404s)Fix guide
- OPS-239Caching plugin conflict (WP Rocket, LiteSpeed) breaking JSFix guide
- OPS-237Contact Form 7 / WPForms / Gravity Forms mail settings brokenFix guide
- OPS-242WordPress core update breaking themeFix guide
- OPS-235Theme update overwrites customisations / tracking codeFix guide
- OPS-248Admin email unverified/old in settingsFix guide