更改mod-rewrite规则以将特定文件请求路由到index.php

时间:2012-04-18 16:05:53

标签: mod-rewrite

我的.htaccess文件中的PHP框架有一个默认规则,它将除特定文件之外的所有请求路由到index.php。

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

例如,如果我在/ images文件夹中有特定于站点的图像,请求 foo.com/images/name.jpg 将直接处理到文件系统。

但我需要针对具有特定路径的URL的特殊行为,例如。 /图片。因此, foo.com/image/name.jpg 等请求也应该路由到index.php ......

1 个答案:

答案 0 :(得分:0)

RewriteRule .*\.(pdf|js|ico|gif|jpg|png|css|rar|zip|tar|gz)$ /index.php [L]