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))$
精彩评论