Mobile app version of vmapp.org
Login or Join
Jessie594

: Website directory structure regarding subdomains, www, and "global" content I am trying to make a homemade HTTP server. It occurs to me, though, I never fully understood what you might call "relativity"

@Jessie594

Posted in: #Directory #Subdomain

I am trying to make a homemade HTTP server. It occurs to me, though, I never fully understood what you might call "relativity" among web pages. I have come across that is a subdomain, and I understand its original purpose. IT sounds like, in general, you would redirect (is that 301 or 302?) it to a... non-subdomain, sort of. As in, redirecting example.com to example.com.

I am not entirely sure how to make this work when retrieving files for an HTTP server though. I would assume that example.com would be the root, and www manifests as a folder within it. I am unsure. There is also the question of multi-level subdomains, e.g. subdomain2.subdomain1.example.com. It seems to me they are structured "backwards", where you go from the root left in folder structure. In this situation, subdomain2 is a directory within subdomain1, which is a directory in the root.

Finally, it occurs to me I might want a sort of global location. For example, maybe all subdomains still use an image as a logo. It makes more sense to me that there is one image, rather than each having a copy. In the same way, albiet more doubtfully, you might have global CSS (though that is a bit contrary to the idea of a subdomain in the first place), or a javascript that is commonly used. (more efficient than each having its copy and better for organization purposes). Finally, mabye you have a global 404 page. I think this might be the case where you have user-created subdomains (say bloggername.example.com), where example.com still has a default 404 when either a subdomain does not exist or page does not exists under a valid blogger.

I am confused on what the directory structure for this should be. To summarize: Should and how it have a global files not in a subdirectory, how should be handled, (or how a now www or other subdomain should be handled), and the pattern for root/subdomain, as well as subdomain within subdomains (order-wise).

Sorry this is multiple questions, but I feel at the root they are all related to the directory.

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Jessie594

2 Comments

Sorted by latest first Latest Oldest Best

 

@BetL925

www is almost never a sub-directory of the website document root. If it were, the web server would have trouble figuring out if it was supposed to be served as example.com/www or example.com
Rather, each domain or sub-domain that is hosted gets its own section in the web server's configuration file and that configuration defines a document root. On my webserver, all websites are stored in the directory /var/www and the directory structure for it might look like:

/var/www/
example.com/
index.html
blog.example.com/
index.html
othersite.tld/
index.html


If I am redirecting example.com to example.com, I would not even create an directory for it. Rather I would just put the instructions to perform that redirect in the web server configuration and not define a document root.

10% popularity Vote Up Vote Down


 

@Murray432

I think perhaps you have some terminology mixed up here, when you bind an IP to a website host on any web server, you should then define a default file system directory and document which then becomes the "root" of the website you are about to host. All other references from here can be relative, sub-domains need to then alias from either the same or new roots based on the DNS record resolving your IP to that domain name.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme