Lighttpd 正则表达式

发布于 2024-09-04 06:08:07 字数 131 浏览 3 评论 0原文

我试图匹配lighttpd $HTTP["url"] 语句中具有 /images/ 、 /styles/ 或 /scripts/ 的任何网址。这怎么可能做到呢?我目前正在使用 "^/images/" 等,并且仅当该目录位于 URL 开头时它才有效。

I am trying to match any url that has /images/ , /styles/ , or /scripts/ in a lighttpd $HTTP["url"] statement. How could this be done? I am currently using "^/images/" , etc. and it's only working if that directory is in the beginning of the URL.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

所谓喜欢 2024-09-11 06:08:07
/(images|styles|scripts)/

将匹配其中包含 /images//styles//scripts/ 的任何字符串。

由于您需要匹配斜杠,因此请使用不同的正则表达式分隔符,例如 !

if ($subject =~ m!/(images|styles|scripts)/!) {
    # Successful match
} else {
    # Match attempt failed
}
/(images|styles|scripts)/

will match any string that has either /images/, /styles/ or /scripts/ in it.

Since you need to match the slash, use a different regex delimiter, e. g. !:

if ($subject =~ m!/(images|styles|scripts)/!) {
    # Successful match
} else {
    # Match attempt failed
}
波浪屿的海角声 2024-09-11 06:08:07

“/图像/|/样式/|/脚本/”

"/images/|/styles/|/scripts/"

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文