【发布时间】:2011-12-14 07:41:16
【问题描述】:
我试图制定一个正则表达式,以与 httpd.conf 文件中的 Apache Web 服务器配置的“位置”指令一起使用。
<Location ~ "/start/.*(?!end1|end2)$">
Order Deny,Allow
Deny from all
Allow from foo.com
</Location>
但是,我在 Apache 日志文件中收到以下错误:
Syntax error on line 1179 of c:/apache/apache/conf/httpd.conf:
Regex could not be compiled
我知道错误可能在“负前瞻”部分:(?!end1|end2),但无法准确确定。 谢谢
【问题讨论】:
-
您使用的是哪个版本的 apache?正则表达式语法在 1.x 和 2.x 之间发生了巨大变化
-
这是来自Oracle应用服务器10g的Apache,应该基于Apache 1.3。
-
即使使用前瞻,表达式:
/start/.*(?!end1|end2)$也不起作用。为确保该位置以/start/开头并且不以end1或end2结尾,这里有一个有效的表达式:^/start/(?!.*end[12]$)
标签: regex apache location httpd.conf