It sounds like too much work.
Yet, you don't realize what everyone is telling you -
you've actually made it too much work by creating this folder "root."
I can't even fully extract the cause of the problem from your posts, but I can tell you what is wrong with a near mathematical certainty, because it's the same problem most PHP coders exhibit - even many experienced ones. This is going to be a path issue, and it's going to be because you're using relative links, as in "relative to where this file is."
First, take their advice and get RID of that "root" folder. Just drag everything out of it and in the
root of your domain. Someone somewhere told you to "put files in the root directory." So you (or someone) created a folder named "root" and put some stuff in there. That is not what it means.
Root describes your domain's root, the root from where your domain tree begins, and it's different in different contexts. It's **really** important you understand this difference or you're always going to struggle with missing images, includes that don't include, and all kinds of other crap that you won't get because you're thinking "relatively."
The root URL/URI is the root of your domain when called from the web. It's simply /, or the fully qualified URL: http://www.example.com.
The
file system root is a completely different animal. Yes, it is the root of your domain, but it's the computers' path to your domain root. You can see whatever this is, at any time, by running phpinfo() or doing this.
echo $_SERVER['DOCUMENT_ROOT'];
Using your example, this is /home/example.com/public_html. (using your domain or user name.) This is not a URL/URL, this is your domain's
file system root. Why is this important? Most PHP code you will see here, and in all the code you'll scrape off the web, does s**t like this: (and it IS! SORRY!)
include('includes/file.php');
include('../includes/file.php');
include('../../../../includes/file.php');
<img src="img.jpg">
<img src="images/img.jpg">
<img src="../images/img.jpg">
<img src="../../../images/img.jpg">
Though it's particularly rampant in PHP, this insanity poisons CSS and Javascript as well:
background: url(../images/bg.jpg);
Note these carefully, we'll use the same examples later. What do all these have in common? The rely on
relative paths, meaning, "Wherever I'm at now, step up or down to these directories and find this file." You can squeak along using this method, but the problem with it is that if something moves, you have to go back and modify all these instances, and you're constantly calculating "where you want to be from where I am now".
That's insane.
Complicate this once more: Many PHP coders treat PHP includes as URL's or URI's.
They are not the same. PHP uses the file system path to include files, while URI's (images, other pages from a browser, whatever) use actual URI/URL's. Why do they do this?
Because it works one time, and they've no reason to believe it won't work forever. Which, as you're discovering, throws you into a tailspin when it doesn't.
In your case, You probably have the exact same file and have to figure out where that file is from the /root directory, then figure out where it is from the actual domain root. So if you have
/root/images/myfile.jpg
and then from /root/index.php,
<img src="images/myfile.jpg">
No problem. It finds it. But if you have the same img code in the index.php
at the actual domain root, of course it won't find it. It's in the /root/images/directory and this code
<img src="images/myfile.jpg">
is not descending into the "root" directory.
Now, don't run off to fix this by putting "root" in front of the "images" in the img src of domain root copy of index.php. That would be a
patch that would eventually resurface in some other page or project. Here is a
permanent fix. Here is what you do: Locate all "web reference paths" and change them to this:
<img src="/img.jpg">
<img src="/images/img.jpg">
<img src="/images/img.jpg">
<img src="/images/img.jpg"> <!-- note that this is now exactly the same as the first two examples! -->
What does this do? It says "DOESN'T MATTER where I am now. Start at the domain root and follow this path."
For all PHP includes, do this.
include($_SERVER['DOCUMENT_ROOT'] . '/includes/file.php');
include($_SERVER['DOCUMENT_ROOT'] . '/includes/file.php');
include($_SERVER['DOCUMENT_ROOT'] . '/includes/file.php'); // Look at that, they are all the same!
This does the same thing, but form the file system path. "Start at the
file system root of this domain and field this file."
Trust me, DO the work, get rid of that root folder, adopt this policy and this problem will go away forever.