I have 3 questions mainly. There are questions like this in the Internet, however I have not found a duplicate question like this in StackOverflow. Anyway, I will appreciate your answer.
I know that www.example.com
is a subdomain of example.com
. So I assume it means that hypothetically I can have two different websites in those two different urls although not recommended. Am I missing something here?
Between example.com
and example.com/
if you don't do a 301 redirect, then will example.com/
show a page directory?
Why do big companies like Google, Amazon, etc. redirect their domain to the www subdomain? (legacy, convention, best practice?)
Your question is not really related to programming hence a little off topic here. For further questions like this have a look at the Webmasters StackExchange website instead, or the ServerFault one for configuration issues.
To answer it quickly based on your title, first two are hostnames, last one with /
is an URL.
To go back to your three points:
Yes you can have completely different websites at each name, so www.example.com
and example.com
do not need technically to show the same website. It might however confuse a lot of people.
Each website will show content based on its configuration. Per se it is impossible to say what will example.com/
show. It can be a page, a redirection, a file listing, an error... No one knows in advance it depends on the configuration at the moment you query it.
Partly subjective: there is a part being a convention and another technical part because it is a little more complicated to use a CDN or other external resources at apex (example.com
) because you can not use a CNAME
record in the DNS there, where you can for www
. See for example how www.amazon.com
is a CNAME
to a CDN.