Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does Wordpress rewrite the URL without a rewrite map?

The .htaccess file for a 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 map set in htdocs. How does this work? How does Apache know how to rewrite these url?

like image 895
jwerre Avatar asked Jan 20 '23 16:01

jwerre


1 Answers

The Apache does not know. All the requests are sent to index.php and Wordpress keeps an internal log of which page to redirect where, and it redirects it. So, in essence, Wordpress actually has two sets of rewrite rules, one internally and a "greedy" external rule in your .htaccess which basically makes all requests refer to the internal rewrite rules.

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

like image 97
shamittomar Avatar answered Jan 29 '23 07:01

shamittomar