使用重写规则将符号链接组合到外部文件夹?

发布于 2024-08-04 00:39:35 字数 560 浏览 4 评论 0原文

我在帐户中创建了一个指向该用户帐户外部文件夹的符号链接(尽管具有相同的所有权)。符号链接有效,但我想将它与 RewriteRule 结合起来,但我遇到了问题。

例如,我使用以下命令创建符号链接:

ln -s /home/target shortcut

并将以下 RewriteRule 添加到 .htaccess:

RewriteRule ^shortcut/([a-zA-Z0-9_-]+) shortcut/index.php?var=$1

但是这会失败。

然而,如果目标文件夹不是位于外部文件夹中,而是与快捷方式地址位于同一文件夹中,则RewriteRule将起作用。即,如果符号链接是:

ln -s ./target shortcut

How might I get the RewriteRule work for the case where the targetfolder is an externalfolder?

I've created a symlink in an account to an folder external to that user account (although with the same ownership). The symlink works but I'd like to combine it with a RewriteRule, and I'm having problems with that.

For instance I create the symlink with:

ln -s /home/target shortcut

And I add the following RewriteRule to .htaccess:

RewriteRule ^shortcut/([a-zA-Z0-9_-]+) shortcut/index.php?var=$1

This however fails.

Yet if instead of being located in an external folder, the target folder is in the same folder as the shortcut address, then the RewriteRule will work. i.e. it works if the symlink is:

ln -s ./target shortcut

How might I get the RewriteRule working for the case where the target folder is an external folder?

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

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

发布评论

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

评论(1

り繁华旳梦境 2024-08-11 00:39:35

问题可能是 [a-zA-Z0-9_-]+ 也会匹配 index.php 中的 index。所以你会陷入无限循环。试试这个:

RewriteRule ^shortcut/([a-zA-Z0-9_-]+)$ shortcut/index.php?var=$1

The problem might be that [a-zA-Z0-9_-]+ will also match the index in index.php. So you’re getting an infinite loop. Try this instead:

RewriteRule ^shortcut/([a-zA-Z0-9_-]+)$ shortcut/index.php?var=$1
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文