WordPress Rewriting Explanation

I found these rewrite rules in the .htaccess of my WordPress site:

RewriteEngine On RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] 

I know that basically this applies to all index.php. But how does it work? What rule does what?

+6
source share
1 answer

I found several links here: http://httpd.apache.org/docs/current/mod/mod_rewrite.html

RewriteEngine On allows you to rewrite a module.

RewriteRule ^index\.php$ - [L] ensures that if index.php is called, no other rules are executed. - must make sure that there will be no rewriting, and the [L] flag indicates that other rules should not be followed.

RewriteCond %{REQUEST_FILENAME} !-f adds a condition to the next rewrite rule. This condition says that the requested file name is not ( ! ) An existing file.

RewriteCond %{REQUEST_FILENAME} !-d the same, but for an existing directory.

RewriteRule . /index.php [L] RewriteRule . /index.php [L] says that everything ( . ) should be rewritten to /index.php and that this is the last rule to execute ( [L] ).

+8
source

All Articles