How does Wordpress rewrite the URL without a rewri

2019-04-09 10:24发布

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?

1条回答
啃猪蹄的小仙女
2楼-- · 2019-04-09 11:01

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.

查看更多
登录 后发表回答