htaccess,如果找不到图像则转到其他位置

时间:2013-12-19 12:50:21

标签: php regex apache .htaccess mod-rewrite

我有一条现在无效的htaccess规则。

    RewriteCond  %{REQUEST_URI} !-f
    RewriteCond  %{REQUEST_URI} ^store/images/products/p(\d+)/cache/([^.]+).card.jpg
    RewriteRule  ^$ index.php?r=backend/product/imageNew/$1/$2 [R,L]

规则应该像这样强制破坏图像:/store/images/products/p6/cache/imagine.card.jpg进入此规则。

请帮助:)

1 个答案:

答案 0 :(得分:1)

由于正则表达式模式匹配冲突,您的规则永远不会触发。

尝试此规则:

RewriteCond %{REQUEST_URI} !-f
RewriteRule ^store/images/products/p(\d+)/cache/([^.]+)\.card\.jpg$ index.php?r=backend/product/imageNew/$1/$2 [R,L]

您在^$中匹配RewriteRule,但在store/...中匹配URI = RewriteCond