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.

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 copies of websites or installing specific software, like forums or a staging copy - useful for creating things like forum.example.co.uk or staging.example.co.uk

Once you've created a subdomain it will have its 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 where 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 subdirectory/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 (opens in a new tab)
© Krystal Hosting Ltd 2002–