I am trying to figure out how exactly WordPress works around blog posts so that I can implement something similar in my web application. And this is probably some basic php, but I can not seem to find out exactly how to do this!
Typically you have a a URL like http://www.example.com/blog/2012/01/27/some-title. And I know that the file http://www.example.com/blog/2012/01/27/some-title/index.php does not exist. What is the path of action that WordPress takes and any php settings that need to be set in order for the html for the blog post to be generated? Is it related to a 404 error page for missing / invalid url paths?
What WordPress does — and indeed many of the popular MVC frameworks — is route ALL traffic to a single Front Controllerwikipedia script using an apache .htaccess file. The component parts of the requested URL are then broken apart by the framework/CMS to determine what controller should be executed to return the requested content. The underlying details of how it determines where to route the request vary from framework to framework.
The front controller will generally handle error displays as well as it (or the determined controller) is able to decide if the requested resource actually exists.
So the path of execution will be something like:
I believe WordPress actually sucks up ALL traffic and points it to the front controller. This is great in the case of the average WordPress user who knows little about PHP programming or .htaccess rules. However, it’s generally advisable to allow requests that reference files or directories that actually exist on the server to still be accessed via conditions in the .htaccess file instead of routing them to the front controller like all other requests.