重定向的一切,这不是一个负面的形象重写规则? [英] Negative rewrite rule for redirecting everything that's not an image?
本文介绍了重定向的一切,这不是一个负面的形象重写规则?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想创建一个重定向的家居一个Apache重写规则不图像文件到一个特定的脚本,但我已经无法使其与^和负向前看符号工作。基本上以下之一匹配,如果它的是的形象,但我不知道如何使它负。
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 unable 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))$
这篇关于重定向的一切,这不是一个负面的形象重写规则?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文