This is the .htaccess code in WordPress. Can someone explain how it works?
^index\.php$ - [L]
prevents requests for index.php
from being rewritten, to avoid an unnecessary file system check. If the request is for index.php
the directive does nothing -
and stops processing rules [L]
.
This block is all one rule, and it says that if it is not a real file and not a real directory, reroute the request to index.php
.
RewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-dRewriteRule . /index.php [L]
index.php itself interprets the URL that was requested by the client (PHP can see the requested URL using $_SERVER['REQUEST_URI']
) and it calls the correct code for rendering the page the user requested.