How many paths...

Author: Shaunk...


I'm confused. Building HTML/CSS sites was pretty straight forward in terms of hierarchy and file specificity. You usually have all the main pages in the root directory, CSS files in the root unless you have a complex set then pop them in a folder for good housekeeping. Then there is just the matter of few folders for images/assets/media and for SEO and edibility purposes you need a folder to contain Scripts (.as, .js, .php etc.) and maybe some sub directories or blog folders.

Now, since the introduction of external actionscript, javascript and PHP things are starting to resemble a kleptomaniacs handbag! PHP and database driven sites are exceptionally confusing, multiple directories, queries, variables, PHP includes and requires then content stored in separate mySQL databases means a page can actually be made up from a huge number of separate pages stored all over the place.

Absolute URL Paths

This is a laborious way of doing things and generates excessive code. I prefer to avoid using this method unless the code needs to be easily movable, independent of other files, reusable or to ensure links remain valid over time/modifications.

These are simple enough just put the URL http://www.website.com/folder/file.php

Document Relative URL Paths
Things get a little more confusing here but it's cleaner code and having to get grips with it is inevitable.
The relative URL points to a file or directory in relation to the present file or directory (folder). Relative URL's help in web site maintenance. It is easy to move a file from one directory (folder) to another, or a web site from one domain name to another. And you don't have to worry about updating the link(s) or the src (img) path(s).

To link to a file in the same directory: file.php
To link to a file in a sub directory: folder/file.php
To link to a file in a parent directory: ../file.php

Root Relative URL Paths
A "/" at the beginning of the path indicates to the computer reading the path that it should start at the site root folder to find the file. This is the top most folder accessible on a server via a WWW browser, usually public_html or similar.

/folder/file.php

Then we get on to server paths, an even more confusing area. Here is an extract taken from http://www.ibdhost.com/help/path/

I've not quite got my head round these yet.

Absolute vs. Relative Server Paths
Absolute Paths

Paths are used ON THE SERVER. Usually inside a script. The absolute path is the "full path". It is the path that contains the top directory (usually home) - the username - the root directory (usually public_html) - the sub directory (or file name) For example
/home/username/public_html/cgi-bin/test.cgi
This is the absolute path to the text.cgi file in the cgi-bin directory

BTW: /home/username/ would put you in the root of your account. An section that is NOT accessible via WWW (browser) - this is where mail files, password files, etc (other protected files) are stored on the server. You seldom need this path since you are working with web pages and need path info to the public_html (www) directory ( your root directory FOR the web)

Example of other useful path information shows the path to shared files on the server. For example the path to perl on the server:
/usr/bin/perl
Path info of this type are supplied by the host when you need it for scripts. In most cases, the cPanel account displays this info for the client. Along with path to 'date' 'sendmail' etc that are required by many scripts.
Relative Path

Relative Path may be a misnomer. It is actually like the relative url i.e. it is normally 'relative' to the public_html directory (which is the root directory for the web site / not the root of the server). However, it could be relative to the upper directories (home). But in actually use, the relative path is seldom used - even in scripts. And if it is required, the script writer may NOT use the name - relative path. It may be referred to as a non-absolute path, a direct path, a path to a file, etc. Bottom line - is that scripts that refer to the relative path - really mean the path to files below the www root (usually public_html). So it is usually the same as the relative URL. And in actual practice it's not 'usually called' a relative path. It's more likely to be referenced as the 'path to files' (or sumsuch :)

 

0 Response to “How many paths...”

Leave a Reply