浏览我的网站时,用户将登陆:
mysite.com/index.php
我想包含子文件夹中的完整 html 文件,而不是使用 iframe。
例如,在目录中,您将找到:
www/index.php(用户正在浏览的文件(
www/subfolder/otherpage.html(要包含
的页面( www/subfolder/images/something.jpg(子文件夹的资产(
当我在根文件夹中包含otherpage.html
时,没有任何路径是正确的。
我的问题是:如何将 ROOT 重置为mysite.com/subfolder/
,以便可以从index.php
中正确包含otherpage.html
?
完整index.php
:
<?php
include('subfolder/otherpage.html');
?>
你试过什么?SO 不会为您提供现成的脚本。您可能希望使用常量或变量。或者,如果您确实无法更改其他页面.html则可能需要手动替换路径。
<?php
ob_start();
include 'subfolder/otherpage.html';
$output = ob_get_contents();
$output = str_replace( 'mysite.com/', 'mysite.com/subfolder/', $output );
print $output;
?>