我在服务器上的以下目录中:
组件在.phtml文件中,但是扩展名被htaccess规则删除了。
现在我想要进入另一个.phtml文件,但是我需要写这个:
<a href="../other-page/"></a>
我注意到我也可以这样做:
<a href="/other-page/"></a>
但这样它就不会跳转到我想要的 http://example.nl/cms/other-page/,而是跳转到了 http://example.nl/other-page/
我该如何更改文档根目录为"cms"
,以便我只需使用单个"/"
?
$_SERVER['DOCUMENT_ROOT']
来生成绝对路径。如果你真的想改变根目录的位置,你需要重新配置你的服务器。 - Pyromonk<base>
元素。如果你在<head>
部分添加<base href="http://example.nl/cms/">
,那么任何指向/other-page/
的链接实际上应该转到http://example.nl/cms/other-page/
。 - rickdenhaan