mod_rewrite 出现多个子目录错误
我尝试在 joomla 中手动使用 mod_rewrite,并且有以下规则:
RewriteRule ^test/(t1|t2|t3)-(.*).html$ /index.php?option=com_jumi&fileid=39&$1 =$2 [L,NC]
这样我希望网址
http://www.mysite.com/index.php?option=com_jumi&fileid=39&t1=foo
显示为
http://www.mysite.com/test/t1-foo.html
规则正常工作,但是当我在重写的页面中时,链接如
http://www.mysite.com/link.html
或 http://www.mysite.com/xxx/link.html
成为
http://www.mysite.com/test/link.html
或 http://www.mysite.com/xxx/test/link.html
分别。
有什么建议吗?
谢谢
I am trying to use mod_rewrite manually in joomla, and I have the following Rule:
RewriteRule ^test/(t1|t2|t3)-(.*).html$ /index.php?option=com_jumi&fileid=39&$1=$2 [L,NC]
So that I want the url
http://www.mysite.com/index.php?option=com_jumi&fileid=39&t1=foo
be displayed like
http://www.mysite.com/test/t1-foo.html
The rule works correctly, but when I am in the rewritten page the links like
http://www.mysite.com/link.html
or
http://www.mysite.com/xxx/link.html
become
http://www.mysite.com/test/link.html
or
http://www.mysite.com/xxx/test/link.html
respectively.
any suggestions?
thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您在页面中使用相对网址。您的页面包含类似
...
的链接,并且浏览器使链接相对于当前“文件夹”,即“test”,因此当单击时浏览器加载/test/link.html
。您应该只使用根相对 url。因此链接应该变得更像
...
。前导“/”使浏览器加载相对于根目录(“/”)的页面,而不是相对于“/test/”。You are using relative urls in your page. Your page contains a link like
<a href="link.html">...
and the browser makes the links relative to the current 'folder', namely "test", so when clicked the browser loads/test/link.html
.You should just use root-relative urls. So the link should become more like
<a href="/link.html">...
. The leading '/' makes the browser load the page relative to the root ("/"), not relative to "/test/".