我需要匹配不包含任何 /管理/
或?页=
。
我会以此作为在iirf.ini文件重定向规则(支持htaccess的语法)。
我怎样才能做到这一点?
解决方案使用负前瞻(?!...)
用正则表达式或(A | B)
:
^(*(/管理/ |?!?页=))
这是说,当位于启动( ^
)的输入应包含的两个测试字符串
I need to match all urls that DO NOT contain either /admin/
or ?page=
.
I'll be using this as a redirect rule in an iirf.ini file (supports htaccess syntax).
How can I accomplish this?
解决方案Use a negative look-ahead (?!...)
with a regex OR (a|b)
:
^(?!.*(/admin/|?page=))
This is saying that when positioned at the start (^
) the input should contain either of your two test strings