开发者

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

开发者 https://www.devze.com 2023-03-23 22:22 出处:网络
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 lookah

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

精彩评论

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