What is a subdomain and how do you set one up?
You want blog.example.org or shop.example.org next to your main site. A subdomain is a name inside a wider domain: in blog.example.org, blog sits under example.org. You can use subdomains to separate a website, mail, an API and other services, but the name alone creates no web page. It needs DNS records and a server configured to answer for it.
Subdomain or folder: blog.example.org versus example.org/blog
blog.example.org is a separate hostname, while example.org/blog is a path on the example.org website. The two can show similar content but are configured differently. A subdomain can point to another server, be served by another application or be handed to a separate team. A path generally stays under the same hostname, although the application behind it can still be independent.
There is no universal rule that subdomains are better for search or for security. Decide on architecture, access control, language handling and maintenance. For a section related to the main site, plan the navigation, internal links and canonical URLs whichever structure you choose.
Which DNS records a subdomain needs
A website commonly uses an A or AAAA record to give the server’s address, or a CNAME to make the subdomain an alias of another name. CNAME comes with a restriction: a name that has a CNAME cannot hold other ordinary records alongside it. If the subdomain receives mail, configure its MX and the associated records as the mail provider requires. Do not copy the parent domain’s records automatically, because the subdomain may serve a different purpose.
A wildcard such as *.example.org can answer for names that are not otherwise defined. It cannot replace application routing, and it does not apply to a name that has explicit records of its own. A subdomain that should have its own DNS zone, for instance one managed by another team, needs delegation through NS records in the parent zone. RFC 1034 and RFC 1035 provide the DNS foundations.
Setting it up and confirming that it answers
The order of work is short:
- Decide what the name represents and which server will accept it.
- Add the record to the active authoritative zone, the one the domain is actually delegated to.
- Query the new name with the 2ip DNS lookup tool and confirm that it returns the record you added.
- Open the site. If DNS returns the expected IP but the page does not load, check the virtual host, the application routing and the TLS certificate for the new name.
The last step catches the most common surprise. DNS only directs visitors to a server; the server must also know the new name, and its certificate must cover it. If nothing resolves at all, look at the parent first: the 2ip domain availability check shows whether the domain itself is registered or still free.
What a subdomain does not give you
For a login page, a separate subdomain alone is no security boundary. Authentication, cookies, permissions and TLS are configured in the application. Moving an existing section to a subdomain also changes its addresses, so you need a plan for the old URLs and internal links.
Subdomains that only look familiar
Lookalike characters and typos can lead to a different domain altogether. Internationalised names have a DNS-compatible ASCII form, and the Punycode converter shows it so that you can see which characters a name really contains. Do not enter a password on an unexpected subdomain just because its ending resembles a familiar address.