2013-04-10 85 views
6

我发现这些重写规则,在我的WordPress网站的.htaccess:说明在WordPress的重写规则

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

我知道,这基本上是指一切的index.php。但它是如何工作的?什么规则做什么?

+0

我有同样的问题(http://stackoverflow.com/q/35303598/2983568),并在这里发现了详细的解释:http://glennmessersmith.com/pages/wphtaccess.html – supafly 2016-02-10 08:04:03

回答

8

我发现这里一些参考:http://httpd.apache.org/docs/current/mod/mod_rewrite.html

RewriteEngine On使重写模块。

RewriteRule ^index\.php$ - [L]可以确保在index.php被调用时,没有其他规则执行。 -是为了确保不会发生重写,并且[L]标志指示不应该执行其他规则。

RewriteCond %{REQUEST_FILENAME} !-f为以下重写规则添加条件。此条件表示请求的文件名是而不是!)现有的文件。

RewriteCond %{REQUEST_FILENAME} !-d是相同的,但对于现有的目录。

RewriteRule . /index.php [L]一切.)应该重写/index.php,并认为这是执行([L])的最后一个规则。