如何“动态地”将 http 请求重定向到文档根目录之外的文件夹
我在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
要么符号链接目录而不是单个文件,要么使用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