Skip to content
FunnelGuard

Fix guide by FunnelsGuard

Sitemap lists staging or wrong-domain URLs: how to fix it

SEO-106Medium impactOther toolBy FunnelGuardPublished Updated
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.

How a wrong-domain sitemap loses visitors
  1. Sitemap publishedEntries use staging.example.com
  2. Search engine reads itHost mismatch: URLs ignored or staging crawled
  3. Staging page indexedDuplicate of the live page
  4. 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

Find wrong-host URLs in your sitemap
  1. 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.

  2. Scan the host names

    View the page source and search for staging, dev, test, localhost, your old domain and the opposite www version.

  3. 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.

  4. Search for the staging host

    Search Google for site:staging.example.com (your actual staging host). Any results mean it is indexed.

  5. Crawl it

    Run a crawler such as Screaming Frog in list mode on the sitemap and sort by host to see every domain used.

List every host used in a sitemapbash
curl -s https://yourdomain.com/sitemap.xml \
  | grep -o '<loc>[^<]*</loc>' \
  | sed -E 's#<loc>https?://([^/]+).*#\1#' \
  | sort | uniq -c

The 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.

Fix the site URL by platform
  1. 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_HOME and WP_SITEURL in wp-config.php.

  2. 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-run once the preview looks right. Take a backup first.

  3. 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.

After the source is fixed
  1. Block staging from search

    Put staging behind a password (HTTP authentication) so it cannot be crawled. A noindex tag or robots.txt block on its own is weaker, and must not be copied to the live site.

  2. 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.

  3. Resubmit the sitemap

    In Search Console (Indexing > Sitemaps) and Bing Webmaster Tools, submit the sitemap again.

Sitemap entries before and after

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

Confirmation checks
  • 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

Launch and migration habits
  • 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.

Does FunnelGuard catch this?

Other tool

Needs a different kind of tool.

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.