使用重写规则将符号链接组合到外部文件夹?
我在帐户中创建了一个指向该用户帐户外部文件夹的符号链接(尽管具有相同的所有权)。符号链接有效,但我想将它与 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题可能是
[a-zA-Z0-9_-]+
也会匹配index.php
中的index
。所以你会陷入无限循环。试试这个:The problem might be that
[a-zA-Z0-9_-]+
will also match theindex
inindex.php
. So you’re getting an infinite loop. Try this instead: