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 this basically refers everything to index.php. But how does it work? What rule does what?
I found some reference here: http://httpd.apache.org/docs/current/mod/mod_rewrite.html
RewriteEngine On
enables the rewrite module.RewriteRule ^index.php$ - [L]
makes sure that ifindex.php
is called, no other rules are executed. The-
is to make sure no rewrite will occur, and the[L]
flag indicates that no other rules should be executed.RewriteCond %{REQUEST_FILENAME} !-f
adds a condition to the following rewrite rule. This condition says that the requested filename is not (!
) an existing file.RewriteCond %{REQUEST_FILENAME} !-d
is the same, but for an existing directory.RewriteRule . /index.php [L]
says that everything (.
) should be rewritten to/index.php
, and that this is the last rule to execute ([L]
).