简体   繁体   中英

php - include html pages outside the root folder

On my php site I'm trying to include html pages outside the root folder (the html pages change automatically)
if I include an html page I get the 404 error for the linked files and if I include the linked files too they aren't displayed correctly
path/site/root/index.php

...
include("path/html/index1.html");
include("path/html/index1_files/img.png");
...

path/html/index1.html

...
<img src="index1_files/img.png">
...


result: 在此处输入图像描述

You need to specify the directory properly. So, in your case, when linking to the image, replace <img src="index1_files/img.png"> with <img src="./index1_files/img.png"> . The ./ goes back into the folder the file is saved in, and../ goes up one level. Your code is looking for a folder called index1_files within the current page.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM