如何“动态地”将 http 请求重定向到文档根目录之外的文件夹

发布于 2024-12-22 03:49:50 字数 1136 浏览 3 评论 0原文

我在 lighttpd 服务器上用 PHP 为几个客户端构建了一个小型自定义 CMS。现在,每个客户端在用户根目录中都有自己的 CMS 副本:

Client1/www/index.php
Client1/www/CMS/includes
Client1/www/CMS/scripts
Client2/www...

为了更好地维护,我决定将 CMS 放入用户根目录之外的额外文件夹中。因此,当我开发 CMS 时,我不必更新每个客户端:

CMS/includes
CMS/scripts
Client1/www/index.php
Client2/www...

要重定向像 www.client1.com/scripts/default.js 这样的 http 请求,我只需在用户根目录中放置一个符号链接即可:

CMS/scripts -> ../../CMS/scripts

到目前为止,一切顺利。但现在项目越来越大,我需要使用不同版本的“CMS”:

CMS_1.0/...
CMS_1.2/...

使用简单的 PHP 包含,这没有问题。我只是在 Client1/www/ 内的一个小配置脚本中将版本声明为 GLOBAL ,并包括如下内容:

include "../../CMS_".$GLOBALS["version"]."/includes/myClass.php";

但是对于所有 http 请求(CSS、JS 和 Ajax 加载的 PHP),我每次都需要编写新的符号链接更改为新版本的“CMS”

CMS/scripts -> ../../CMS_1.0/scripts

问题:

有什么方法可以将 www.client1.com/scripts/default.js 重定向到../../CMS_1.0/scripts 使用符号链接中的 $version 等变量或通过配置 lighttpd 或任何其他方式?

我希望你们能理解我的问题...

I built a small custom CMS for a couple of clients in PHP on a lighttpd-server. Right now every client has an own copy of the CMS in the user-root:

Client1/www/index.php
Client1/www/CMS/includes
Client1/www/CMS/scripts
Client2/www...

For better maintenance I decided to put the CMS into an extra folder outside the user-root. So I don't have to update every single client when I develop the CMS:

CMS/includes
CMS/scripts
Client1/www/index.php
Client2/www...

To redirect a http-request like www.client1.com/scripts/default.js I simply put a symlink in the user-root:

CMS/scripts -> ../../CMS/scripts

So far, so good. But now the project is getting bigger and I need to use different versions of "CMS":

CMS_1.0/...
CMS_1.2/...

With simple PHP-includes this is no problem. I just declare the version as a GLOBAL in a little config-script inside Client1/www/ and include like:

include "../../CMS_".$GLOBALS["version"]."/includes/myClass.php";

But for all the http-requests (CSS, JS and Ajax-loaded PHP) I would need to write new symlinks every time I change to a new version of "CMS"

CMS/scripts -> ../../CMS_1.0/scripts

Question:

Is there any way I can redirect www.client1.com/scripts/default.js to ../../CMS_1.0/scripts using a variable like $version in the symlink or by configuring lighttpd or any other way?

I hope you guys understand my problem...

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

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

发布评论

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

评论(1

深空失忆 2024-12-29 03:49:50

要么符号链接目录而不是单个文件,要么使用lighttpd的mod_alias作为脚本目录: http:// redmine.lighttpd.net/wiki/1/Docs:ModAlias

Either symlink the directory instead of single files or use lighttpd's mod_alias for your scripts directory: http://redmine.lighttpd.net/wiki/1/Docs:ModAlias

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