为 mvc 前端控制器设置 .htaccess



我对设置前端控制器所需的.htaccess文件有一个简单的问题。此配置之间有什么区别:

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

而这个:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule !.(css|js|icon|zip|rar|png|jpg|gif|pdf)$ index.php [L]

RewriteRule ^(.+)$ index.php/$1 [L]

此规则将所有请求转发到索引.php文件,而不考虑请求的文件类型

RewriteRule !.(css|js|icon|zip|rar|png|jpg|gif|pdf)$ index.php [L]

而此规则只会转发对索引的请求.php这些请求不在指定扩展名的列表中。

最新更新