WordPress requests

This will be some logical covering of the WordPress request - the initiation of the web request in WordPress that is simple like this:

You type the URL and WordPress needs to handle that URL and needs to present the correct data.

It starts from the index.php file = the very first file WordPress executes with the every request…


then the wp-blog-header loads some initialization and calls the wp() function.


wp() functions takes the query vars and should create the global $wp_query object.


before creating that object we need to parse the request.


Here comes the idea of rewrite rules in WordPress, since these are the rules stored in the options table and predefined to improve the SEO.


There are more the 100 rules. You can also create these rules, if you need special URL structures to be understood by WordPress to present your data with your special templates and query type meaning.


In WordPress index.php handles all requests. This is why your Apache configuration files probably contain the following lines:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

and your nginx rolls with:

if (!-e $request_filename) { rewrite ^(.*)$ /index.php last; } 

Of course if you don’t have those rewrite rules you’re probably using some of the default.


permalink structures, where the request /2011/10/15/sample-post is already being passed to index.php.

There are two types of rewrite rules in WordPress:

  1. internal rules = stored in the database and parsed by WP::parse_request()

  2. external rules (stored in .htaccess and parsed by Apache if you are on Apache).

tags: & category: -