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…

Selection_005

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

Selection_006

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

Selection_007

before creating that object we need to parse the request.

Selection_008

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.

Selection_009

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.

Selection_010

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.

http://abc.de/index.php/2011/10/15/sample-post/

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: -