ゆるテックノート

Why “www” showed up in front

Back in the day, “www.example.com” was the default look. “www” was a simple subdomain saying “this is the web server.” Not mandatory, but there were practical reasons it spread.

How “www” became a thing ⏳

Admins used to split services by subdomain: www for web, mail for mail, ftp for FTP—one host, one role.

Early habits

  • Servers often handled a single service; hostnames mapped almost 1:1 to boxes.
  • DNS labels made roles obvious: www=web server, ftp=file transfer, mail=SMTP/IMAP.
  • Virtual hosting wasn’t widespread yet, so splitting by hostname was natural.

DNS reasons and perks 🧭

Adding “www” sometimes simplified DNS and hosting setups.

Apex vs. CNAME

  • The apex (example.com) can’t be a CNAME; pointing www to a CDN via CNAME was a common workaround.
  • www could be CNAME to CDN, while the apex used A/AAAA for on-prem or another role.

Cookies and subdomains

  • Limit cookies to www and keep static.example.com cookie-free to save bandwidth.
  • Subdomains help separate scopes with same-origin in mind.

Use it—or not—today 📌

Both approaches are fine; pick based on simplicity or operational needs.

Why skip it

  • Short, clean URLs (serve from the apex).
  • ALIAS/ANAME and modern DNS make apex + CDN easier than before.

Why keep it

  • Flexibility: CNAME www to CDN while apex does something else.
  • Cookie/CORS scope separation by subdomain.
  • Preserve existing URLs and SEO/bookmarks.

Practical tips

Whatever you choose, make it canonical.

Recommendations

  • Pick www or apex as canonical and 301-redirect the other.
  • If using HSTS preload, choose carefully which host you preload.
  • Check cookie domain settings and CORS origins match your choice.