Apache2 (HTTPD) 位置标签是通配符匹配吗?

J J*_*nes 4 apache apache2

好消息是我已经解决了我的问题,坏消息是我不明白这个问题!

URL: http://host:port/a/b
Run Code Online (Sandbox Code Playgroud)

配置文件

<Location /a>
 ProxyPass to Server....
</Location>

<Location /b>
 ProxyPass to some other Server
</Location>
Run Code Online (Sandbox Code Playgroud)

在此设置中,我的请求http://.../a/b将我带到“其他服务器”而不是预期的“服务器”

我能够通过强制更多“regex-y”行为并使用表达式开头(又名:

<Location ~ "^/a">
 ProxyPass to Server....
</Location>
Run Code Online (Sandbox Code Playgroud)

如果我必须这样做,那很好。但是文档在这种情况下似乎相当不清楚。

文档来源:位置标签上的 Httpd 文档http://httpd.apache.org/docs/2.0/mod/core.html#location似乎暗示位置匹配以非正则表达式方式(又名,没有~)确实不使用通配符(这就是为什么他们有一节解释如何使用通配符和正则表达式)。此外,最后的斜线讨论也不意味着它使用通配符。

所以,我只能假设我在我的 Apache 版本中发现了一些错误。或者也许我只是使用了太相似的 URL 结构而无法理解 Apache 文档。帮帮我,StackOverflow!

ALO*_*low 5

如果您参考Apache 文档,它清楚地指出

也可以使用正则表达式,并添加 ~ 字符。例如:

<Location ~ "/(extra|special)/data">

将匹配包含子字符串 /extra/data 或 /special/data 的 URL。