开发者

Negative rewrite rule for redirecting everything that's not an image?

I'm trying to create an Apache rewrite rule that redirects everything that is not an image file to a specific script, but I've been 开发者_如何学JAVAunable to make it work with ^ and negative lookaheads. Basically the following one matches if it is an image, but I am not sure how to make it negative.

RewriteCond %{REQUEST_FILENAME} (.*\.(png|bmp|jpg|gif))$
RewriteRule .* ./not-an-image.php

Any help? Thanks!


Just use a ! to make it a reverse the match.

RewriteCond %{REQUEST_FILENAME} !(.*\.(png|bmp|jpg|gif))$
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜