Uma possível solução seria escrever uma expressão regular que não corresponda aos URLs que você deseja excluir.
A correspondência em AliasMatch
e algumas outras diretivas no Apache Web Server usa PCRE .
A maioria das distribuições GNU / Linux tem pcre-tools
pré-compilada. Este pacote contém algumas ferramentas, pcregrep
e pcretest
, muito úteis para testar expressões regulares compatíveis com Perl:
$ cat <<EOF>test.txt
> /plugins/git
> /plugins/foo
> /plugins/bar
> EOF
$ pcregrep '^/plugins/(?!git)' test.txt
/plugins/foo
/plugins/bar
$ pcretest
PCRE version 8.33 2013-05-28
re> /^\/plugins\/(?!git)/
data> /plugins/git
No match
data> /plugins/foo
0: /plugins/
Nesse caso, a subexpressão (?!git)
é conhecida como lookahead negativo :
Lookahead assertions Lookahead assertions start with (?= for positive assertions and (?! for negative assertions. For example, \w+(?=;) matches a word followed by a semicolon, but does not include the semi- colon in the match, and foo(?!bar) matches any occurrence of "foo" that is not followed by "bar". Note that the apparently similar pattern (?!foo)bar does not find an occurrence of "bar" that is preceded by something other than "foo"; it finds any occurrence of "bar" whatsoever, because the assertion (?!foo) is always true when the next three characters are "bar". A lookbehind assertion is needed to achieve the other effect. If you want to force a matching failure at some point in a pattern, the most convenient way to do it is with (?!) because an empty string always matches, so an assertion that requires there not to be an empty string must always fail. The backtracking control verb (*FAIL) or (*F) is a synonym for (?!).