If I want to apply a rule to only some files in apache2.conf, I can use <FilesMatch>.
For example:
<FilesMatch ".(gif|jpg|jpeg|png|mpg|avi)$">
deny from env=hotlink
</FilesMatch>
But is there a opposite to FilesMatch, i.e. a FilesNotMatch?
What I want to achieve is:
<FilesMatch ".(gif|jpg|jpeg|png|mpg|avi)$">
<FilesNotMatch "ban">
deny from env=hotlink
</FilesNotMatch>
</FilesMatch>
(deny hotlinking of all images on a server BUT banners)
Or do you have a suggestion how I could modify my regexp to not match anything that contains "ban" ?
Sadly there doesn't seem to be a way to negate a file match in Apache.
However, the regular expression library that Apache uses is PCRE (Perl Compatible Regular Expressions). This means you have the full power of Perl's regexes, including their negative lookbehind and lookahead assertions. These are fairly complicated and powerful features. I can't be certain that this will work, especially without knowing the full layout of your images, but you might be able to use something like:
Almost correct - you need to use
\b(?!.*ban.*)(.+)\.(gif|jpg|jpeg|png|mpg|avi)$
regexp for such exception.