How does Wordpress rewrite a URL without rewriting?

The .htaccess file for the wordpress site looks something like this:

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

... and there is no rewrite set in htdocs. How it works? How does Apache know how to rewrite this URL?

+4
source share
1 answer

Apache does not know. All requests are sent to index.php , and Wordpress saves the internal log on which the page is redirected and redirects it. So, essentially, Wordpress has two sets of rewrite rules: one inside and a β€œgreedy” external rule in your .htaccess, which basically makes all requests a reference to internal rewrite rules.

You may be interested in using this plugin , which shows all the internal rewrites that Wordpress itself does.

+8
source

Source: https://habr.com/ru/post/1336840/


All Articles