Friday, May 9, 2008

Understanding Absolute Paths in Dreamweaver

Sooner or later you'll want to include hyperlinks (links) in your Dreamweaver webpages. Whenever you create a link to another page in your website you have to enter a path to that file or location. Images also have paths to their source. Dreamweaver manages these paths pretty well as long as the files are within your website folder.

Sometime you need to add links to web pages or files outside your website folder. This kind of hyperlink is called an absolute or full path. It is the full URL (Uniform Resource Locator, a pointer to a "resource" on the World Wide Web) to a web page. The path points to the exact location of the file on the internet. This type of file is always begins with the file transfer protocol (HTTP, FTP, File, and so on).

An absolute path is like a house address. For example: 3333 Sycamore Lane, Raffian, Ohio 44703 is a complete address.

The link to the Scripps TSR-EYE site (http://www.scripps.edu/services/tsr-eye/index.html) is an example of an absolute path. It contains the entire path to a file on the internet. If you use absolute links to other websites on your web page, be sure to check to see if they are still valid from time to time.

An absolute path or full URL can consist of up to five sections, listed below:

  • Protocol - The first part of the URL is the protocol. It is http for web pages to indicate Hypertext Transfer Protocol (HTTP). Sometimes you might want to link to a file on a File Transfer Protocol (FTP) server (another method of communication over the Internet to move files to and from a server), using ftp instead of http as the protocol in the URL.
  • Domain – The second part of the address is the domain. This is the name of the web server where the web page is located. The domain of the TSR-EYE link is www.scripps.edu. A colon and two forward slashes (://) separate the protocol and the domain.
  • Port – An optional third part of a URL is the port. If the port is not specified, the default port for the protocol is used instead. The default port for a web server is port 80. When you enter http as the protocol, port 80 is implied and doesn’t usually need to be included.
  • Path and filename – The fourth part of the address is the path and filename. The path includes all directories and the filename. In our TSR-EYE sample, the pathpath is /services/tsr-eye and the filename is: /index.html. Most web pages end in .htm or .html. Other common file endings are .cgi for Common Gateway Interface; asp for Active Server Pages; .jsp for JavaServer Pages; .aspx for ASP.NET files; .php for PHP pages; and .cfm for ColdFusion Markup language.





  • Query string – The filenames might be followed by an optional fifth part of a URL – a query string. The query string is added to a URL to send data to a script for processing. The “?” tells the browser that the following part is a variable. Anything after the '?' in a URL is called the "Query string" A typical URL format containing a query string is as follows: http://server/path/program?query_string.

    The graphic below illustrates a URL with a Port listing and Query string.


The absolute paths to the YouTube videos are another example of query strings:

http://www.youtube.com/watch?v=frvVJJv63gg (Link to a Dreamweaver tutorial about Defining a your Local Root/Site Folder)

You might see a URL that does not have a filename referenced at the end, such as http://www.scripps.edu/services/tsr-eye. No specific file is referenced in the URL, only the final directory is included ("/tsr-eye" in this case).This type of address works because the web server looks for a default page in the directory. Most web sites have a default page name that doesn’t need to be explicitly entered at the end of the URL. Usually the default page name is welcome.html, default.htm, default.html, index.htm or index.html. On some servers, any of these names will work.

Default pages in the root of a site are often referred to as home pages. To create a home page for a website, ask your webmaster or web hosting service for the default page name for your web server. If you don’t have a default page on your website and a visitor doesn’t enter a filename at the end of the URL, that person might see all the contents of your directories instead of a web page. Or the user might get an error message.

Most browsers don’t require that you enter the protocol into the browser’s address box to go to a web page. The browsers assume that you want to use the HTTP protocol to access a web page. However, if you are surfing to an FTP file, you have to enter ftp as the protocol at the beginning of the URL. Even though browsers assume HTTP, you still need to preface absolute links entered into Dreamweaver with http://.

No comments: