: Directory structure and script arguments I'll often see a URL that looks something like this: site.com/articles/may/05/02/2011/article-name.php Surely all of those subdirectories don't actually exist?
I'll often see a URL that looks something like this:
site.com/articles/may/05/02/2011/article-name.php
Surely all of those subdirectories don't actually exist? It seems like it would be a huge redundancy, even if it was only an identical index file in every directory. To change anything you'd have to change every single one.
I guess my question is, is there some more elegant way that sites usually accomplish this?
More posts by @Ann8826881
2 Comments
Sorted by latest first Latest Oldest Best
The subject you need to look into is called a Rewrite engine.
Basically, a dynamically generated page (eg a CMS page) needs to get parameters sent to it via the URL so that it knows what content to display. For example, if a site only needs to know the article id in order to get that article's content from the database, then that page may initially have the URL site.com?id=24.
A rewrite engine could tidy that URL up so that it becomes site.com/24 or site.com/anything/24. It just needs to know the "24"
It could even remove the id, just so long as a database query could work it out from its replacement. For example... site.com/articletitle could allow a database query to ask "what is the id of the article with the title articletitle", before generating that page.
The example you give is pretty poor, as the date is back-to-front. However, the wikipedia entry has some nice examples of it in proper use:
en.wikipedia.org/wiki/Rewrite_engine
(It is very unlikely that a static site would use such a directory structure)
Actually these are often blog sites and often with static rather than dynamic content, though not always. The URL you are referring to is automatically maintained by the software which creates, recreates, or updates the site according to what is in it's database. The URL structure is often an option. I do not see the advantage to having a directory path that is a date other than allowing for topics with similar or identical article names which can often happen on a blog - especially a blog where more than one person participates in.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2025 All Rights reserved.