On this page
What this issue is
An XML sitemap is a file, usually at /sitemap.xml, that lists the pages you want search engines to crawl. Each entry sits inside a <loc> tag. This issue means some or all of those <loc> values use the wrong host. Common examples are staging.example.com, dev.example.com, example.staging-host.com, localhost, an old domain from before a rebrand, or a www and non-www mix-up.
Why it costs you leads or sales
Google's sitemap rules say a sitemap should only list URLs on the same host as the sitemap file (with limited exceptions when ownership is verified for both). URLs on other hosts are typically ignored, so your real pages get less help being found. If the staging site is publicly reachable and not blocked, those pages can be crawled and indexed as duplicates. They can then compete with your live pages, and visitors can land on a half-finished copy where forms, checkouts and tracking do not work.
- Sitemap publishedEntries use staging.example.com
- Search engine reads itHost mismatch: URLs ignored or staging crawled
- Staging page indexedDuplicate of the live page
- Visitor lands on stagingBroken forms, no real tracking
The sitemap sends crawlers to the wrong host, so the live page is under-discovered and the staging copy may rank instead.
How to check if your site has it
Open the sitemap
Visit
https://yourdomain.com/sitemap.xml(or/sitemap_index.xml,/wp-sitemap.xml). If it is an index, open each child sitemap too.Scan the host names
View the page source and search for
staging,dev,test,localhost, your old domain and the oppositewwwversion.Check Search ConsoleGoogle Search Console
Under Indexing > Sitemaps, open the sitemap report. Errors such as 'URL not allowed' or 'URL not in property' point to host mismatches.
Search for the staging host
Search Google for
site:staging.example.com(your actual staging host). Any results mean it is indexed.Crawl it
Run a crawler such as Screaming Frog in list mode on the sitemap and sort by host to see every domain used.
curl -s https://yourdomain.com/sitemap.xml \
| grep -o '<loc>[^<]*</loc>' \
| sed -E 's#<loc>https?://([^/]+).*#\1#' \
| sort | uniq -cThe output should show one host only, your live one. Any other line is a problem. For a sitemap index, run the command against each child sitemap.
How to fix it
The cause is almost always one setting: the site address your platform uses to build links. Fix that at the source, not by editing the XML by hand, because generated sitemaps overwrite manual edits.
Correct the address settings
Go to Settings > General and set WordPress Address and Site Address to your live https URL. If the fields are greyed out, check
WP_HOMEandWP_SITEURLinwp-config.php.Replace old URLs in the database
Use a search-replace tool such as WP-CLI
wp search-replace 'https://staging.example.com' 'https://example.com' --dry-run, then run it again without--dry-runonce the preview looks right. Take a backup first.Regenerate the sitemap
In Yoast SEO or Rank Math, save the permalinks (Settings > Permalinks > Save) and clear the plugin and site caches. The sitemap rebuilds from the corrected address.
Check the primary domain
Go to Settings > Domains and make sure your live domain is set as primary. Shopify builds
/sitemap.xmlfrom the primary domain.Remove stray domains
If an old or test domain is still connected, set it to redirect to the primary domain.
Set the default domain
In Project settings > Publishing, make your custom domain the default and publish to it. The auto-generated sitemap uses the default domain.
Check a custom sitemap
If you pasted a custom sitemap XML in SEO settings, replace any staging URLs in it and republish.
Connect and set the primary domain
In Settings > Domains, set your live domain as primary. Wix generates the sitemap for the primary domain.
Set the primary domain
Go to Settings > Domains and set your live domain as primary. Squarespace builds
/sitemap.xmlfrom it automatically.
Use a configured base URL
Make the sitemap generator read the base URL from an environment variable (for example
SITE_URL), and set it per environment. Never hard-code a host.Rebuild and deploy
Regenerate the sitemap in the production build and confirm the file on the live server, not in your local output folder.
Block staging from search
Put staging behind a password (HTTP authentication) so it cannot be crawled. A
noindextag or robots.txt block on its own is weaker, and must not be copied to the live site.Redirect indexed staging URLs
If staging pages were indexed, 301 redirect them to the live equivalents where possible, or remove them with the Removals tool in Search Console.
Resubmit the sitemap
In Search Console (Indexing > Sitemaps) and Bing Webmaster Tools, submit the sitemap again.
Before
- <loc>https://staging.example.com/pricing/</loc>
- Search Console reports host mismatch
- Staging pages appear in search results
After
- <loc>https://example.com/pricing/</loc>
- Sitemap reads without host errors
- Only live pages are submitted for indexing
How to confirm it's fixed
- The host-listing command shows one host only, your live domain.
- Every child sitemap in the index has been checked, not only the first.
- The sitemap loads over https with no redirect to another host.
- Search Console shows the sitemap as Success with no host errors after it is re-read.
site:search for the staging host returns nothing, or the pages redirect.- Staging is behind a password.
How to prevent it happening again
- Add 'check the sitemap host' to your go-live and migration checklist.
- Keep the site URL in environment config, not in content or code.
- Run a search-replace with a dry run after every staging-to-live copy.
- Password-protect staging and dev sites.
- Re-check the sitemap after domain changes, plugin switches and CDN or proxy changes.
- Schedule a monthly crawl of the sitemap and flag any host that is not your live one.
How FunnelGuard handles this
FunnelGuard does not check this yet. Reading sitemap hosts is a possible future check, but today it is not part of the service.
What FunnelGuard does do is run your real customer journeys on a schedule, such as lead forms, checkouts and booking buttons, and check each step, the tracking hits sent to ad and analytics platforms, and whether test leads reach your inbox and CRM. If visitors end up on a broken staging copy of a page in a journey you monitor, a failed step or missing tracking could show up there, but that is an indirect signal, not a sitemap check.
Questions people ask
Why does my sitemap show staging URLs?
Your CMS or plugin builds sitemap links from the site address stored in its settings or database. If you copied a staging site to live without updating that address, the sitemap keeps using the staging host. Correct the site URL, search-replace the database and regenerate the sitemap.
Will Google index URLs from the wrong domain in my sitemap?
Google generally ignores sitemap URLs on a different host unless you have verified ownership of both. The bigger risk is that the staging site is public and gets crawled through links or the sitemap, creating duplicate pages that compete with your live ones.
How do I find staging URLs in my sitemap?
Open the sitemap in a browser and search the source for words like staging, dev, test and localhost. For a full check, run a command that extracts the host from every <loc> tag and counts them. Only your live host should appear.
How do I fix a WordPress sitemap with the wrong domain?
Set WordPress Address and Site Address to your live URL in Settings > General, check wp-config.php for hard-coded values, and run a search-replace on the database. Then save permalinks and clear caches so Yoast, Rank Math or the core sitemap rebuild.
Can I just edit the sitemap XML by hand?
Not for long. Generated sitemaps are rebuilt automatically and overwrite manual edits. Fix the site URL setting or the base URL in your generator so the correct hosts are written every time.
How do I stop my staging site being indexed?
Put it behind HTTP password protection so crawlers cannot reach it. A noindex tag or robots.txt block helps but can be copied to the live site by mistake. If pages were already indexed, redirect them or use the Removals tool in Search Console.
Does FunnelGuard check my sitemap for wrong-domain URLs?
No. FunnelGuard does not check sitemap hosts yet; it is a possible future check. It does monitor your real funnels, tracking and lead delivery, so use a scheduled script or crawler for the sitemap itself.
Related issues
- SEO-105Sitemap lists 404, redirect, noindex or canonicalised URLsFix guide
- SEO-107Sitemap lists http URLs on an https siteFix guide
- SEO-104Sitemap stale: new pages missingFix guide
- SEO-101Sitemap not submitted in Search Console / Bing WebmasterFix guide
- SEO-103Sitemap XML invalid or wrong namespaceFix guide
- SEO-113Plugin generates duplicate sitemaps (Yoast plus Rank Math)Fix guide