The difference between a sub-domain and a sub-directory or folder

When your cPanel account is created it uses your primary domain e.g. example.co.uk

You'll notice there's nothing in front (e.g. www.) or behind (e.g. /blog) your domain name at this point.

A Fully Qualified Domain Name (FQDN) contains both a hostname and a domain name e.g. mysite.example.co.uk - where mysite is the hostname and example.co.uk is the domain name.

Sub-domain - the part in front of the domain name

Within cPanel > Domains you'll see an option to add a Subdomain. This can be used to create separate websites - useful for creating things like dev.example.co.uk or staging.example.co.uk

Once you've created a subdomain it will have it's own web root folder and you can upload your site there.

Although www looks like a subdomain (and technically is) - this is often just a CNAME DNS record pointing at the domain.

Sub-directory - the part behind the domain name

You can create a folder or sub-directory within any web root folder (you can do this in cPanel File Manager).

For example, if your primary domain was example.co.uk and this website was being served from the public_html web root folder - if you create a sub-directory within public_html called blog and place web files there they could be viewed at example.co.uk/blog

But, aren't subdomains just folders?

Yes, and no! When you create a subdomain cPanel creates a new sub-directory/folder within your web root - and this folder is where your web site files should be placed.

Because this folder is at your web root level - not under public_html - the files in it will only be accessible from the subdomain.

For example, if example.co.uk was your primary domain, served from /public_html you could create a sub-directory/folder called blog - web files here would be accessible at example.co.uk/blog

AND

you could also create a subdomain blog.example.co.uk - and any files placed in this subdomains folder within web root would be accessible via blog.example.co.uk


How did we do?


Powered by HelpDocs
© Krystal Hosting Ltd 2003–2019