访问文档根范围之外的文件

发布于 2024-08-09 02:31:38 字数 552 浏览 6 评论 0原文

我正在编写一个脚本来构建一个动态网站, 该网站是通过加载外部组件创建的。

DocumentRoot 位于 /sites/website/public 组件目录位于 /sites/website/components

我想根据请求的 url 到达每个组件的数据目录。

例如:

网址:

http://ibuildmywebsite/component-data/randomimage/demo/ swan04090044_small.jpg

应该获取文件 /sites/website/components/randomimage/data/demo/swan04090044_small.jpg

我怎样才能实现这一点? 我更喜欢一种可以放置在 .htaccess (如果有的话)内部的方法,而不是修改虚拟主机定义。

谢谢!

I'm writing a script to build a dynamic website,
the website is created by loading external components.

The DocumentRoot is location at /sites/website/public
the components directory is located at /sites/website/components

i wannna reach the data directory of each component depends on the requested url.

for example:

the url:

http://ibuildmywebsite/component-data/randomimage/demo/swan04090044_small.jpg

should fetch the file /sites/website/components/randomimage/data/demo/swan04090044_small.jpg

how can i achieve that ?
i would prefer a way that can be placed inside .htaccess (if there is one) instead of modifying the virtual host definitions.

Thanks!

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

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

发布评论

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

评论(1

梦幻之岛 2024-08-16 02:31:38

也许将 RewriteRule 与 Alias 结合起来?

Alias /randomimage /sites/website/components/randomimage
RewriteRule ^component-(.*)/randomimage/(.*)$ /randomimage/$1/$2 [R,L]

(虽然在 .htaccess 中不起作用)

您也可以使用符号链接:

Options +FollowSymLinks

并将 components-*/randommimage/* 动态链接到 /sites/website/components/randomimage/*/ */

Combine RewriteRule with Alias maybe ?

Alias /randomimage /sites/website/components/randomimage
RewriteRule ^component-(.*)/randomimage/(.*)$ /randomimage/$1/$2 [R,L]

(Won't work in .htaccess though)

You could probably also use Symlinks with:

Options +FollowSymLinks

And link dynamically components-*/randommimage/* to /sites/website/components/randomimage/*/*/

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