Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

image/test.gif or http://www.test.com/image/test.

Status
Not open for further replies.
as far as i know there both the same, i think its just up to personal preference. I learned a bit yesterday, today i learned a lot, imagine what i'll learn tomorrow!
 
What are relative URLs?
Put simply, it's an URL which needs some processing before it is valid. It is a local URL, from which certain information is left out. Often this means some directory names have been left off, or the special sequence ../ is being used.
The "relative" comes from the fact that the URL is only valid relative to the URL of the current resource.

Resolving relative URLs
As said, a relative URL needs the URL of the current resource to be interpreted correctly. With some simple manipulations, the relative URL is transformed into an absolute URL, which is then fetched as usual.
A relative URL is always a local URL. The first part is therefore always the same as that of the current URL. The relative URL is then turned into an absolute local URL with the following simple steps:

Omit the filename of the current absolute local URL, if it's not a directory URL.
For every ../ at the beginning of the relative URL, chop off one directory name from the current directory URL.
Append the local URL to the current one.
Here are a few simple examples:
Current document:
Relative URL: myessay.html.

The full URL for this relative URL is
Relative URL: pics/background.gif.

The full URL for this relative URL is
Relative URL: ../cgi-bin/myscript.pl.

The full URL for this relative URL is
Note that it is not necessarily true that the ../ bit in a relative URL refers to going "up" one directory on the server. It may often be the case, since that's the most simple and common way to do it, but the ../ applies to the URL, not the actual directory tree on the server.

As you can see in the last example, it is quite possible that ../ ends you in a totally different directory on the server.
Infinity exists! - I just haven't worked out a way to get there yet.

| |
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top