My error page includes an image from
root/img/404.png
When user accesses wrong links like "root/aaa", the image is displayed, but when the user accesses "root/aa/aa" the error page is displayed but the image is not loaded.
My question is: how to include a file which can be shown in every different level?
Generally speaking, images are included using <img>
tags, not php include() statements. But in both cases, the key is to start from the root level - e.g., for img this would be <img src="/img/404.png">
instead of <img src="img/404.png">
Without the leading /, the img file (or include file or whatever) is loaded relative to the current directory, which you have shown varies depending on the user's page request.