包括文件夹,即使文件已被排除

时间:2020-05-13 20:44:23

标签: apache .htaccess mod-rewrite

除图像文件外,我有以下规则来重写所有url路径和查询以 route 的形式访问index.php。但是,如果图像位于specific_folder内部,则也希望它们也通过index.php路由。

我的.htaccess现在看起来像这样:

RewriteBase /

RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*\.(gif|jpg|jpeg|png|webp)
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]

这使我可以重写除图像文件之外的所有内容以作为 route 进入index.php。但是,如果图像位于specific_folder内部,则也希望它们也通过index.php路由。

我在图像文件扩展名条件之后添加了以下行,但它似乎不起作用:

RewriteCond %{REQUEST_URI} /specific_folder/.*$

0 个答案:

没有答案