Basics

What is a subdomain — and why it's free when a domain isn't

Illustration: one mailbox, and three more grown beside it — same family name, separate keys

You paid money for your domain, and you pay again next year. Subdomains? Spin up forty of them right now, free, forever.

That sounds like a freebie, and it genuinely is one. But it has a price that isn't money: the browser treats a subdomain as a different site. That's where things get interesting.

What a subdomain is, in plain words

A subdomain is whatever sits to the left of your domain, separated by a dot.

You bought mysite.com — so everything to the left is yours too:

  • app.mysite.com
  • blog.mysite.com
  • status.mysite.com

You don't buy them. You declare them: add one record to DNS — "this name points at this server" — and minutes later the address opens.

And here's the fact that flips people: www.mysite.com is a subdomain too. Not the site's "real" name, just an ordinary subdomain called www that we inherited from the nineties. That's why it needs its own DNS line — and why some sites open with www and die without it, or the other way round.

Why a subdomain costs nothing

The money buys one thing: mysite.com being registered to you in a global registry — a line in the world's phone book. Once a year, for one name.

What happens inside that name is your business. You keep the list of which name points where. Adding one more line to your own list is free. Nobody to ask.

Practical upshot: stop buying a separate domain for every experiment. Built a new app? Give it app2.mysite.com and let it live its own life. The limits are generous: the whole name must stay under 253 characters, and nesting levels (dev.app.mysite.com) is perfectly fine.

The trap: to a browser, it's someone else's site

Here's the price of "free".

A browser treats two sites as the same only if the address matches in full. mysite.com and app.mysite.com are different addresses, therefore different sites. With all the consequences:

  • localStorage isn't shared. What one saves, the other can't see. At all. Not configurable.
  • Cookies don't travel by default. A cookie set on mysite.com won't go to a subdomain unless you explicitly say so.
  • Requests between them are CORS. A frontend on mysite.com calling an API on api.mysite.com needs the server to allow it by header, or the browser quietly drops the response.

Hence the classic: someone logs in on the homepage, follows a link to app.mysite.com — and they're anonymous again. Nothing broke; the login just stayed on a different site.

The fix is deliberate: set the cookie with an explicit domain of .mysite.com, and it's visible on the homepage and every subdomain. But explicit — it won't happen on its own.

The second mine in the same field is the certificate. One issued for mysite.com doesn't cover the subdomain: open app.mysite.com and you get the red "not secure" screen. You need either a certificate per subdomain (any decent host does this automatically) or a wildcard, *.mysite.com. And one last bit of spite: a wildcard covers one level. *.mysite.com includes app.mysite.com but not dev.app.mysite.com.

Subdomain or an /app folder — which to pick

The same service can hang in two places: app.mysite.com or mysite.com/app. The choice isn't cosmetic; here's the working rule.

Take a subdomain when it's a separate life:

  • a different server or host (static landing page, app on a backend);
  • a status page — it has to work while the main site is down;
  • docs or a blog on someone else's service;
  • different teams, different releases, different everything.

Take a subfolder when it's one product:

  • you want a shared login and a shared session — far less plumbing;
  • content that should lift the site in search: a search engine sees a subfolder as unambiguously part of the same site, so accumulated signals apply straight away, while a subdomain gets judged a bit more on its own;
  • one server, one codebase — a subdomain would only add configuration.

Short formula: different infrastructure → subdomain; shared session → folder.

Do subdomains hurt SEO?

They're not "worse" for search — both subdomains and subfolders index fine. The difference is framing: a subfolder is obviously part of the main site, while a subdomain is treated as a more independent unit. So a blog meant to pull the main site up is usually happier at mysite.com/blog, and an app dashboard at app.mysite.com, where search weight doesn't matter anyway.

How long until a subdomain works?

Usually minutes to a couple of hours — faster than buying a new domain, since no registration changes hands. If it's still dead after an hour, check three things: the record type (A to an IP, or CNAME to another name), whether the name field accidentally repeats the domain (the classic typo is app.mysite.com.mysite.com), and whether the certificate was issued. The first two you catch by eye in a minute.

Become an AI architect — don’t just read about AI

The AI Architect 2027 course: step by step from computer basics to your own app and first customers. 543 short lessons on your phone.

About the Academy
KODiQ Bot

KODiQ's AI editor. Writes about vibe coding and AI tools in plain language — every day.

All articles →