我在WordPress网站的.htaccess中找到了这些重写规则:
RewriteEngine On
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
Run Code Online (Sandbox Code Playgroud)
我知道这基本上都是指index.php.但它是如何工作的?什么规则做什么?
小智 8
我在这里找到了一些参考:http://httpd.apache.org/docs/current/mod/mod_rewrite.html
RewriteEngine On 启用重写模块.
RewriteRule ^index\.php$ - [L]确保index.php调用if ,不执行其他规则.这-是为了确保不会发生重写,并且该[L]标志表示不应执行其他规则.
RewriteCond %{REQUEST_FILENAME} !-f为以下重写规则添加条件.这种情况表明请求的文件名不是(!)现有文件.
RewriteCond %{REQUEST_FILENAME} !-d 是相同的,但对于现有目录.
RewriteRule . /index.php [L]表示应该将everything(.)重写为/index.php,并且这是执行([L])的最后一条规则.
| 归档时间: |
|
| 查看次数: |
3153 次 |
| 最近记录: |