48

I am trying to create url like sub2.sub1.subdomain.domain.com. I am planning to use this to display different content.

my questions are...

1) Is it possible to create such multi level sub domains? - is this based on the hosting company?
2) Isn't sub2.sub1.subdomain a different subdomain rather than a sub domain of sub1?
3) Will all of these subdomains have their own doc roots?
4) How will I handle users coming with and without www.

Any other potential issues that might arise?

EDIT:- How does this affect the behaviour of cookies? Can I access a cookie set on subdomain.domain.com on sub1.subdomain.domain.com or sub2.sub1.subdomain.domain.com

4 Answers 4

47

Is it possible to create such multi level sub domains?

Yes. You can have as many levels as you like in DNS.

is this based on the hosting company?

Your host might limit what you are able to do.

Isn't sub2.sub1.subdomain a different subdomain rather than a sub domain of sub1?

That isn't a useful distinction.

Will all of these subdomains have their own doc roots?

Assuming that all the subdomains end up resolving to the same IP address (and they really don't have to):

Browsers will send the FQDN in the Host header. How the webserver handles that depends on the webserver.

You can configure a separate Document Root for each — and you should (to avoid duplicate content penalties in search engines), unless you are going to do stuff to dynamically determine the content based on the FQDN.

How will I handle users coming with and without www.

However you like. www is only another subdomain without any special properties (other than convention). It is widely considered to be a good idea to pick either "with www" or "without www" as your canonical primary site and redirect the other one to it.

0
14

You.can.go.as.deep.as.you.want.example.com.

1) This is mostly dependent on your DNS - usually, your hosting company manages this; also, if you have a wildcard 3rd-level domain (*.example.com), then any domain name under example.com will point to the same host. So, it is possible and works in 90% of the cases.

2) It doesn't matter, really - it all depends on #3

3) If you configure them for different docroots, they will; else they won't.

4) Check the Host: header - there you'll see what the domain is (with PHP, this data would be in $_SERVER['HTTP_HOST']), and you can implement some switching logic in your code.

1
1
  1. You can go up to what ever sub level you want to (up to the Hosting Provider Limit, if any).
  2. The best example is the folder Level. All are different spaces. It's like C:\Program\Files\Adobe\Acrobat 5.0\Reader
  3. Yes, all sub domains are their own root. Same as the example shown above. Except, here you have the privilege to specify the root file/folder.
  4. Requests without www.* is handled by your hosting company. If the hosting company supports requests without it, then the request will get the specific file/folder.
-3

You can remove www by host panel or htaccess/web.config (by os default) bad rooting, however if you're using nginx, there's no htaccess file.

Subdomains have their own doc roots.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .