在lighttpd中包含许多重写指令

发布于 2024-07-05 06:20:24 字数 544 浏览 3 评论 0原文

我在并行子目录中有很多项目,它们都有 etc/lighttpd.conf 文件。 文件非常简单; 它们只包含一个如下所示的指令:

url.rewrite-once = ("^/project(.*)$"=>"project/router.php?args=$1")

不幸的是,我刚刚发现我不能简单地循环它们,因为我会收到“重复的配置变量”错误。 我发现我应该使用它的方式是这样的:

url.rewrite-once = (
    "^/project1(.*)$"=>"project1/router.php?args=$1"
    ,"^/project2(.*)$"=>"project2/router.php?args=$1"
)

但是,如果我让每个目录的配置文件只包含重写,并让 shell 脚本构建它们,我就不能真正放置任何其他轻量级指令在每个目录文件中。 话又说回来,我是 Lighty 的新手,所以也许我不需要而且只是没有意识到这一点。

这样做的“正确方法”是什么?

I have a bunch of projects in parallel subdirectories that all have etc/lighttpd.conf files. The files are very simple; they just include a directive that looks like this:

url.rewrite-once = ("^/project(.*)$"=>"project/router.php?args=$1")

Unfortunately, I just discovered that I can't simply loop through them, because I'll get a "duplicate config variable" error. I see that the way I'm supposed to use it is like this:

url.rewrite-once = (
    "^/project1(.*)$"=>"project1/router.php?args=$1"
    ,"^/project2(.*)$"=>"project2/router.php?args=$1"
)

However, if I make my per-directory config files just include the rewrites, and have a shell script build them, I can't really put any OTHER lighty directives in the per-directory files. Then again, I'm new to lighty, so maybe I don't need to and just don't realize it.

What's "the right way" to do this?

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

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

发布评论

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

评论(1

狼性发作 2024-07-12 06:20:24

尝试:

url.rewrite-once += ("^/project1(.*)$"=>"project1/router.php?args=$1")

将新配置附加到现有变量,而不是再次定义它。

try:

url.rewrite-once += ("^/project1(.*)$"=>"project1/router.php?args=$1")

to append your new config to the existing variable instead of defining it again.

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