Skip to content
FunnelGuard

Fix guide by FunnelsGuard

Different robots.txt on www and non-www or http/https: fix

SEO-011Medium impactOther toolBy FunnelGuardPublished Updated
On this page

What this issue is

A robots.txt file tells search crawlers which URLs they may fetch. It applies only to the exact protocol, host and port it is served from. So https://example.com/robots.txt does not govern https://www.example.com/, and the http:// version is a separate file again.

The problem appears when these versions differ. A common case: the main site has a clean file, but an old server, a CDN rule or a leftover staging config still serves Disallow: / on the other hostname. Another case: /robots.txt is not redirected the same way as normal pages, so each host answers with its own file.

Why it costs you leads or sales

Search engines may discover your pages through links, sitemaps or old URLs on any host. If the host they land on serves a blocking or outdated robots.txt, they treat those URLs as off limits. Pages can stop being crawled, new landing pages may not get picked up, and rankings can slip with no obvious error on your side.

It is also hard to spot. You open your site, the file looks fine, and nobody checks the other three hostnames. Impact is usually medium, but it can be severe if the blocking file sits on the host most of your backlinks point to.

How a mismatched robots.txt loses traffic
  1. Link to www hostBacklink or old sitemap points to www
  2. Fetch www/robots.txtServes Disallow: / from old config
  3. Pages not crawledCrawler treats URLs as blocked
  4. Rankings and leadsFewer visits to landing pages

A crawler arrives on a host that serves a different, blocking file.

How to check if your site has it

Request the robots.txt from all four combinations and compare the status code, any redirect and the content. Replace example.com with your domain.

Compare robots.txt on every hostbash
for h in http://example.com http://www.example.com https://example.com https://www.example.com; do
  echo "== $h/robots.txt"
  curl -sIL -A 'Mozilla/5.0' "$h/robots.txt" | grep -iE '^(HTTP|location|content-type)'
  curl -sL "$h/robots.txt" | head -n 8
done
What to look for in each result
ResultMeaningAction
301 to your canonical host, then 200 text/plainHealthyNone
200 with different rulesHost serves its own fileRedirect or align the file
200 with Disallow: /Possible staging leftoverFix urgently
404, 5xx or HTML pageMissing or broken fileSee the related robots.txt guides
Certificate error on httpsHost not properly securedFix the certificate or redirect

Also open Google Search Console. Add each host as a property (or use a Domain property) and check Settings > Crawl stats > robots.txt to see the file Google fetched and any errors for that host.

How to fix it

Make every host return the same robots.txt
  1. Choose one canonical host

    Decide on https plus either www or non-www. Use the one already in your canonical tags and sitemap.

  2. Redirect all other hosts with a 301

    Redirect http to https and the non-canonical hostname to the canonical one, for every path including /robots.txt.

  3. Fix the file on the canonical host

    Make sure it holds only the rules you want and includes a Sitemap: line with the full https URL.

  4. Remove stray copies

    Check the server, CDN and any old hosting for extra robots.txt files or rules that answer on other hostnames.

  5. Re-run the check

    Run the curl loop again and confirm all four versions end on the same 200 response.

Where to set the redirect
  1. Set the site address

    Under Settings > General, make WordPress Address and Site Address use your canonical https host.

  2. Redirect at server level

    Add a host redirect in .htaccess, nginx or your host's control panel. Check no plugin or physical robots.txt file differs from the virtual one.

Redirect all other hosts to https://example.comnginx
server {
  listen 80;
  listen 443 ssl;
  server_name example.com www.example.com;
  # ssl_certificate lines go here
  if ($host != "example.com") { return 301 https://example.com$request_uri; }
  if ($scheme = http) { return 301 https://example.com$request_uri; }
}
Four hosts, one outcome

Before

  • https://www serves the clean file
  • http://www serves an old Disallow: / file
  • /robots.txt not redirected on non-www
  • Crawlers see different rules per link

After

  • Every host 301 redirects to one canonical host
  • One robots.txt with a Sitemap: line
  • Same rules whichever URL a crawler starts from

How to confirm it's fixed

Confirmation checks
  • All four host and protocol versions of /robots.txt end on the same final URL
  • The final response is 200 with content type text/plain
  • The file contains no unintended Disallow: / rule
  • Search Console shows a successful fetch for the canonical host
  • A sample page on each old host redirects to the canonical page with a 301

How to prevent it happening again

Prevention habits
  • Keep redirect rules in one place (server, CDN or platform) and document them
  • Recheck all hostnames after migrations, SSL changes, CDN changes or domain moves
  • Keep robots.txt in version control and review changes before release
  • Never copy staging config to live without a robots.txt review
  • Add a calendar reminder to run the curl check monthly

How FunnelGuard handles this

FunnelGuard does not check this yet. Comparing robots.txt across hostnames is a possible future check, but today it is not part of what the service monitors.

What FunnelGuard does do is run your real customer journeys (lead forms, checkouts, booking and chat buttons) on a schedule from the EU or the US, check the tracking hits sent to ad and analytics platforms, and confirm test leads reach your inbox and CRM. That catches funnel breaks, but not crawler access rules.

To watch for this issue, run the curl loop above on a schedule, and keep the canonical host verified in Google Search Console, where the robots.txt report shows fetch errors. A free read-only FunnelGuard website audit is also available if you want a general look at your site.

Questions people ask

Does robots.txt apply to both www and non-www?

No. A robots.txt file applies only to the exact protocol, host and port it is served from. www.example.com and example.com are different hosts, so each needs to serve the intended file or redirect to the one that does.

Why is Google ignoring my robots.txt changes?

You may have edited the file on a different host than the one Google crawls. Check http, https, www and non-www versions. Google also caches robots.txt for up to about 24 hours, so changes can take time to show.

Should I redirect robots.txt from www to non-www?

Yes, if non-www is your canonical host. Google follows redirects for robots.txt, so a 301 from the other host to the canonical file is fine. Just make sure the final response is a 200 plain text file.

Does http vs https matter for robots.txt?

Yes. The http and https versions are treated as separate hosts. Redirect http to https for all paths, including /robots.txt, so crawlers always end on the https file.

How do I check robots.txt on all versions of my domain?

Use curl -IL on each of the four URLs (http and https, with and without www) and compare the status, redirect target and content. In Google Search Console, the robots.txt report shows what Google fetched for each host.

Do subdomains share the same robots.txt?

No. Each subdomain, such as blog.example.com, needs its own robots.txt file. Rules on the main domain do not apply to it.

Can a different robots.txt on one host hurt my rankings?

It can. If a host serves a blocking file and crawlers reach your pages through it, those URLs may not be crawled or updated. Redirecting every host to one canonical version removes that risk.

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.