Losing clicks to competitors? Find out exactly why, and what to fix first.

Show me why
Skip to content

Technical SEO

Does Robots.txt Apply to Subdomains and HTTP vs HTTPS?

Add saadrazaseo.com as a preferred source on Google

Takes about a minute. You hear back from me personally.

No. A robots.txt file applies only to the exact host, protocol and port where it is served. Rules on www.example.com do not cover blog.example.com, and a file on http does not govern https. Every subdomain you want to control needs its own robots.txt at its own root.

What counts as a separate site

  • www.example.com and example.com are different hosts.
  • shop.example.com is a different host from the main domain.
  • http and https versions are treated separately.
  • A non-standard port is its own origin.

Why this causes problems

A staging subdomain with no rules can be crawled and indexed, and a blog subdomain may lack the restrictions you set on the main site. Teams often fix the main file and forget the others.

Not sure if this is hurting your site?

Get the fixes that matter most, in priority order.

Find my blockers

How to manage several files

  1. List every host and subdomain that serves public pages.
  2. Open /robots.txt on each one and read it.
  3. Create a file where one is missing, using the robots.txt generator.
  4. Check each with the tester.

Keep one version of your site

Redirect alternate versions, such as http to https and non-www to www, to a single preferred address so only one robots.txt matters. Check redirects with the redirect checker.

Subdomain or subfolder?

This is one reason many sites prefer subfolders: one file, one set of rules. I compare the options in ccTLD vs subfolder vs subdomain.

Protect staging properly

Do not rely on robots.txt to hide a staging site, because blocked URLs can still appear in results through links. Use password protection, as explained in noindex vs canonical vs robots.txt.

Frequently asked questions

Can one file cover all my subdomains?

No. Each subdomain needs its own file.

What about a file in a subfolder?

It is ignored. The file must sit at the root of the host.

Next steps

If you run several subdomains and want them checked, contact me here.

More in this series (robots.txt testing questions): start with Robots.txt Tester and AI Crawler Checker, then explore:

Is this holding your site back?

Share your website and I will look at the technical issues holding it back.

Your details are only used to reply to your request. No spam.

Grow my trafficCall