On this page
What this issue is
A staging site is a private copy of your website where you build and test changes. Localhost is the address of a site running on a developer's own computer, such as http://localhost:8080. Neither is meant for the public.
A broken call to action (CTA) is a dead end. The visitor clicked because they wanted to buy or enquire, and they get a connection error, a password prompt or a blank page. Most won't come back.
- Ad clickVisitor lands on live page
- Click CTALink goes to staging.example.com
- Form or checkoutNever reached
- ConversionLead or sale not recorded
The visitor reaches the live page, but the main button points to a staging address.
How to check if your site has it
You are looking for any URL that contains your staging host, a development host or localhost. Check the page source, not just what the page shows, because the visible text of a button can look right while its link is wrong.
Search the page source
Open the live page, view source (Ctrl+U or Cmd+Option+U) and search for
staging,localhost,127.0.0.1,.local,dev.and your host's temporary domain.Click every CTA while logged out
Use a private window. Click the main buttons, menu items, footer links and form submit buttons, and note where each one lands.
Check the hidden places
Look at the canonical tag, Open Graph tags, sitemap, form action attributes, embedded scripts and image sources, not only visible links.
Test on mobile
Some themes and builders keep a separate mobile menu or button, which can hold a different link.
[...document.querySelectorAll('a[href], form[action]')]
.map(el => el.href || el.action)
.filter(u => /localhost|127\.0\.0\.1|staging|\.local|dev\./i.test(u))
.forEach(u => console.log(u));How to fix it
The fix is to replace the old host with your live domain everywhere it appears. Where you do it depends on how the site is built.
Back up first
Take a full database backup before changing anything.
Run a search and replace
Use a search-replace plugin or WP-CLI to swap the staging URL for the live URL across the database. It handles serialized data safely, which a plain SQL replace does not.
Check builder and theme settings
In Settings > General confirm WordPress Address and Site Address are the live domain. Then check Elementor, Divi or theme options for hard-coded button links and regenerate CSS or cache.
Clear caches
Purge your caching plugin, server cache and CDN so old HTML is not served.
Search theme code
In Online Store > Themes > Edit code, search for the staging or localhost host across all files.
Check navigation and content
Review Online Store > Navigation, section settings in the theme editor, pages, blog posts and email-linked pages for hard-coded URLs.
Use relative links
Where possible use relative paths such as /products/your-product, or Liquid objects, so the link follows the domain.
Search tags and variables
In your container use the search box for the staging host. Look at Custom HTML tags, constant variables and triggers.
Fix and publish
Edit the links, preview in Tag Assistant, then publish a new version.
Check link settings
Select each button and link, open Settings and confirm the URL or page selection. Prefer the Page option over typed URLs.
Check site-wide places
Review Navbar, Footer, symbols or components, custom code in Project Settings and embeds.
Republish
Publish to your custom domain so the changes go live.
Review funnel and website steps
Open each funnel or site page and check button links, form redirect URLs and custom code elements.
Check form and workflow settings
Confirm the form redirect or thank-you URL and any links inside emails or workflow actions use the live domain.
Save and publish
Publish each edited page again.
Check each button link
In the editor select the button, click the link icon and confirm it targets a page or your live URL.
Check menus and footer
Open the Menus & Pages panel and the footer, then fix any external link pointing to a test address.
Publish
Publish the site and recheck in a private window.
Review buttons and navigation
Check button blocks, header and footer navigation and any Code blocks for typed URLs.
Check Code Injection
In Settings > Developer Tools > Code Injection (plan dependent), search for old hosts.
Save
Save changes and reload the live page.
Search the codebase
Run a project-wide search for the staging host and localhost in templates, config files, environment variables and JavaScript bundles.
Move the host into configuration
Use an environment variable or a base URL setting per environment instead of hard-coded hosts.
Rebuild and deploy
Rebuild assets, deploy and clear any CDN cache.
wp search-replace 'https://staging.example.com' 'https://www.example.com' --dry-run
wp search-replace 'https://staging.example.com' 'https://www.example.com' --skip-columns=guidBroken
- Button href is https://staging.example.com/book
- Visitor sees an error or a password prompt
- No lead is created
Fixed
- Button href is https://www.example.com/book
- Booking page opens normally
- Lead arrives in inbox and CRM
How to confirm it's fixed
- Page source no longer contains staging, localhost or dev hostnames
- The console snippet returns no results on your key landing pages
- Every main CTA opens the correct live page in a private window
- Form submit and thank-you page work on desktop and mobile
- Canonical and Open Graph URLs use the live domain
- Caches and CDN are purged
- A test lead reaches your inbox and CRM
How to prevent it happening again
Most cases come from hard-coded absolute URLs and rushed launches. Small habits remove most of the risk.
- Use relative links or page pickers instead of typing full URLs
- Keep the base URL in one setting per environment
- Add a launch step: search the database and code for the staging host
- Block search engines and public access on staging with a password
- Re-test key journeys after every migration, theme update or push from staging
- Monitor the live journeys on a schedule so a bad link is caught within hours
How FunnelGuard handles this
FunnelGuard detects this today. A robot visitor runs your real customer journey on a schedule, clicks the CTAs and checks each step. If a link leads to a broken page or an error instead of the expected content, the step fails. The check looks for broken links and for expected text that is missing from the page it lands on.
A failure is re-checked from a second region before one alert goes out, so a one-off glitch does not wake you up. The alert (email, Slack, Teams, WhatsApp, webhook or PagerDuty) includes a screenshot and a likely cause. Test traffic is marked with utm_source=funnelguard and fg_test=1. The Free plan covers 1 site and 2 journeys with daily checks and no card.
Day 0
Site is copied from staging to live. The Book now button keeps its staging link.
Day 1
Ads keep sending traffic. Page views look normal.
Day 5
Enquiries fall. Nobody knows why.
Day 6
A scheduled journey check fails and an alert arrives with a screenshot.
Day 6
Link is replaced with the live URL and the journey passes.
Questions people ask
Why do my website links go to a staging site?
The site was copied from staging to live and some links kept the old absolute URL. This often happens with buttons, menu items and page-builder content typed with a full address. A search and replace on the database or code fixes it.
How do I find all staging links on my live website?
View the page source and search for your staging hostname, localhost, 127.0.0.1 and dev. For a whole WordPress site, run a dry-run search-replace to count matches. For custom code, search the whole project, including config and JavaScript files.
Why does my button link to localhost?
A developer added the link while working on a local copy and it was saved into the content or code. Visitors can't open localhost because it points to their own computer. Replace it with your live URL or a relative path.
How do I replace staging URLs with live URLs in WordPress?
Back up the database, then use a search-replace tool or WP-CLI to swap the staging URL for the live one. Do a dry run first, and clear all caches afterwards. Also check page-builder and theme settings for hard-coded links.
Can staging links hurt my SEO?
Yes, they can. If canonical tags or internal links point to staging, search engines may be confused about which page to index. Fix them, and keep staging blocked from public access.
How can I stop staging URLs reaching my live site?
Use relative links, store the base URL in one environment setting and add a pre-launch search for the staging host. Re-test your key journeys after each migration. Scheduled monitoring catches anything that slips through.
Will analytics show that visitors hit a staging link?
Usually not clearly. Analytics records the landing page view on the live site, then the visitor leaves for a different host. You see a drop in conversions rather than an error, which is why a journey check helps.
Related issues
- CNV-092Main CTA links to a 404Fix guide
- CNV-093CTA links to the wrong page (old offer, wrong product)Fix guide
- CNV-103Navigation link to pricing/contact brokenFix guide
- CNV-104Footer contact links outdatedFix guide
- CNV-109Links with http:// causing redirect hopsFix guide
- CNV-111Ad landing page URL redirects and strips UTMs/gclidFix guide