Tutorial: URL
Author: Martin Warning
Year: 2007
Introduction
URLs are what you need to access a document and link documents, images, CSS, JavaScript and ASP files. In other words URLs are the glue that ties the internet together. When using URLs there are 2 methods that can be used: absolute paths or relative paths.
Absolute Paths
Absolute paths are straight forward as the complete path needs to be used like "http://flyinglowlander.com/Tutorials/ URL/default.asp". The big disadvantage of using absolute paths for an URL as that when the whole web site moves that all these URLs need to be updated. Moving sites from one domain to another doesn't happen very often, but often sites are create on a users machine before being uploaded to the sites server. When absolute paths are used all these pages would need to be modified before being uploaded to the server.
Relative Paths
Relative paths indicate how to get to the document in the URL relative to the document containing the URL. For example to link from this page to the front page of the flyinglowlander.com we need to go up to directories. Moving up directories can be done with "../" which will move up one directory. So the relative path would be "../../default.asp" as we need to move up 2 directories. We can also link to any other folder on the website. For example if we wanted to link to the XHTML section the URL would be "../../ASP/default.asp". The big advantage of using relative paths is that the sites remain portable. It wouldn't matter where the flyinglowlander.com web site would be installed the relative paths would keep working, whereas the absolute paths would need to be modified.
Default Document
On most web servers you can define a default document the server should send to the user when just a directory is requested. For example when going to the website "http://flyinglowlander.com" the web server automatically send the page default.asp to the users browser. This can be further extended like this site does. Instead of linking to documents it uses just the directory name as URL. This is a little cleaner, but doesn't have any other benefits and in fact has the risk that if the server is not configured correctly that the wrong document or a page not found is shown.
In IIS you need to open the web sites properties (you can also configure this per folder) and go to the Documents tab. On this tab you can enable the default document and modify the list of default documents the web server should look for. It is important that this configured correctly for the root of the server as users will only type the sites URL and not the documents URL (ie. only http://flyinglowlander.com).
ASP on IIS and Relative Paths
As of IIS 6 relative paths in ASP include files are not supported by default, but are still supported. To enable support you need to open the web sites properties in IIS and go to the Home Directory tab. Click on the Configuration button in the Application Settings area. In the Application Configuration window that opened you need to select the Options tab. Now select the Enable parent paths option and your are all set.
QueryString VS. Folders
When creating dynamic pages in ASP, JPS or PHP it's easy to create one document that can display many pages. All that is required is to pass parameters to the document to determine what to display to the user. This allows method simplifies web development a lot for web developers (1 code page instead of many), but some search engines are reported to not handle parameter based pages very well.
As such many advice to use folders as a method to pass parameters. For example the page we're looking for is "Introduction to XHTML", we could link to a document called "default.asp?ID=4" which would be efficient and work well. The problem is that many search engines use folder/file name to index a sites content. Thus default.asp?ID=4 doesn't tell us much about the content. Even worse it wasn't until recently that Google started accepting pages using the ID parameter.
Instead using "XHTML/Tutorials/introduction/" is more descriptive. Search engines will index this page better as the URL contains keywords. The problem is that this method would require creating a page in the "XHTML/Tutorials/introduction/" folder which would be a lot of additional work. Instead you can use custom 404 page not found pages to redirect to the default.asp page and use the URL as the parameter. This allows us to create one document for all the different pages and still use search engine friendly URLs.