How does WordPress internal url rewrite work?

WordPress’s htaccess file (generally) looks like this.

<IfModule mod_rewrite.c>  
RewriteEngine On  
RewriteBase /wordpress/  
RewriteRule ^index.php$ - [L]  
RewriteCond %{REQUEST_FILENAME} !-f  
RewriteCond %{REQUEST_FILENAME} !-d  
RewriteRule . /wordpress/index.php [L]  
</IfModule>

Using this Rewrite rule, Apache redirects not found URLs to index.php. And then PHP processes the URL and gives us the relevant data. I have read this at many places.

Read More

But actually how does PHP redirect? I would like to understand the technique behind this redirect.

I mean is it using PHP header() function? Or some other technique?

Related posts

Leave a Reply

2 comments

  1. What the rules mean in plain english:

    1. If the url is /wordpress/index.php, stop processing rules.

    2. If the requested non-empty url is not a file or a directory, hand the request over to /wordpress/index.php and stop processing rules.

    Internally, WP then considers the original url, matches it against known route patterns using regular expression, and sets the request type and parameters accordingly.