Understanding Website URL's
URLs (Uniform resource locators) are everywhere today. On business cards, in newspapers, emails and of course on websites. But what exactly is a URL?
URL Definition:
A URL is defined as the absolute address of a web page/resource on the Internet.
The above URL is an absolute URL, in that, all parts are specified.
The domain name is in effect the name of the Web site or web server and is discussed in more detail in domain names.
The protocol in this case http is the hypertext transfer protocol which is used by web browsers to get web pages, and is the most common one you will encounter. Other protocols you may see here are:
Absolute Versus Relative URL's
Absolute URL's which specify the resource exactly as in the example above must used to access resources that are not on your Web site. If the resource is on your Web site then either a relative URL or absolute URL can be used.
A relative URL or relative path tells the browser the resources position relative to the current position ( web page). If we look at the file layout for our website as shown below:
If you are currently reading the web page create-webpage.htm and want to access the page publishing.htm then the relative path is simply--- publishing.htm-- as both files are in the same directory.
In order to access the file index.htm then the pathname is -- ../index.htm. in this case the two dots .. take the browser up a directory. To access the file image1 in the images directory then the pathname would be ../images/image1.
When accessing files on your own Web site you can use relative or absolute pathnames. When accessing web pages on other site you must always use the full pathname or absolute URL.
Links to Bookmarks or Named anchors
In order to link to a particular part of a web page then a bookmark or name anchor needs to be created in the web page.
Using the above example above and assuming a book mark called middle has already been created on the publishing.htm web page, then the absolute URL to link to this is:
URL=http://build-your-Website.co.uk/courses/publishing.htm#middle.
Where the bookmark is designated by #middle
to link to this from within the publishing.htm page then the relative link is simply:
#middle.
Absolute or Relative URLs for Internal Pages
Although you can use relative links for linking to pages within your own site some webmasters use absolute links.
My preference is to use relative for links in the main navigation and in the site content.
Questions?
Do you have a website related question? If so just ask the web master and I will do my best to help.
Related articles and tutorials:
