php include from index.html
我正在尝试使用php包含在网页上包含文章。。。我的文件结构如下所示:php include from index.html,php,path,server-side-includes,Php,Path,Server Side Includes,我正在尝试使用php包含在网页上包含文章。。。我的文件结构如下所示: /文章 /文章 App_Template.html /标签 /新的 index.html /包括 File.html 在App_Template.html中,我有一段代码: <?php include("../including/File.html"); ?> 我已经试着四处搜索,寻找原因,但是找不到任何原因说明为什么这在这里不起作用,而是在App_Template.html中,我唯一能想象的
- /文章
- App_Template.html
- /标签
- /新的
- index.html
- /新的
- /包括
- File.html
<?php include("../including/File.html"); ?>
我已经试着四处搜索,寻找原因,但是找不到任何原因说明为什么这在这里不起作用,而是在App_Template.html中,我唯一能想象的是这与第二个案例是index.html这一事实有关?你不能在路径中使用三个点
…
,向上一级为。
,当前级为
。如果您想升级两个文件夹/级别,请使用我访问www.my-site.co.uk/new/index.html时有效的。/../yourfile
确定。。。然而,当我刚进入www.my-site.co.uk/articles/new/时,它仍然不起作用:/是否有任何简单的方法可以让这两种方法都起作用?否则,我将不得不将指向特定标记的所有链接更改为/tag_name/index.html;)包括与脚本所在位置相关的工作。如果您在yoursite.co.uk/articles/new/index.html中,并向上移动1个目录,那么您将进入yoursite.co.uk/articles/。如果您在yoursite.co.uk/new/index.html中,并进入1个目录,那么您将进入yoursite.co.uk/,该目录可能没有您想要的文件(反之亦然)。我希望你能明白。解决这个问题的一个方法是在您使用的每个include中使用完整路径/home/a1696768/public_html/articles/tags/new/index.html
,这样可以避免您猜测要访问多少目录(…或..//或更多)。嗯,出于某种原因,除非我访问相应的index.html,否则这仍然不起作用!这是因为文件夹的自动页面需要一定的时间才能像上传favicon一样更新吗?我只能猜测你在这里尝试的是什么:include只能从你的index.html中进行包含,你的文章不知道它们是从其他地方包含的。如果你正在寻找像yoursite.co.uk/article/example-article这样的好的URL,请搜索“mod rewrite”,web和Stackexchange上也有很多教程和问题。
<?php include(".../including/File.html"); ?>
Warning: include(.../including/File.html) [function.include]: failed to
open stream: No such file or directory in
/home/a1696768/public_html/articles/tags/new/index.html on line 79
Warning: include() [function.include]: Failed opening
'.../including/File.html' for inclusion
(include_path='.:/usr/lib/php:/usr/local/lib/php')
in /home/a1696768/public_html/articles/tags/new/index.html on line 79