Where does the absolute path begin?

advertisements

Possible Duplicate:
Absolute path & Relative Path

This is a very basic question, but I have been scratching my head over this for a long time and I am hoping someone can help clear up my confusion.

I have a shared account on a linux server.
The path to public_html is: /home/myusername/public_html The code for my website lives here: /home/myusername/public_html/mysite.com Under mysite.com there are directories such as 'mycss', 'myjs', 'myphp', etc. When I create an absolute path (for example, within php code or an html file), sometimes the path needs to start at /home, eg /home/myusername/public_html/mysite.com/myphp/myfile.php And sometimes it needs to start inside mysite.com, eg /myphp/myfile.php

My confusion: When does an absolute path need to start at /home, and when does it need to start within mysite.com? Is there a rule of thumb, or some insight anyone can give?


You are confusing two types of absolute / relateive.

IF you are speaking in website terms (images / js / html stuff), your absolute is the path from your root website folder (ie: /home/myusername/public_html/mysite.com)

So if you have a folder like:

/home/myusername/public_html/mysite.com/images/bob.jpg

In your HTML, the absolute path would be /images/bob.jpg, while a relative website path would be images/bob.jpg etc;

IF you are doing PHP / Server side includes, you need to use the FULL absolute path, so your whole /home/myusername/public_html/mysite.com stucture.

But also at the same time, if you want to use a relative method (preferred in most cases as it makes your PHP code easier to move) you would just do an include('../database/connect.php');