URLs, full, absolute path and relative path

  • : Function ereg() is deprecated in /home/squtch/drupal-5.23/includes/file.inc on line 646.
  • : Function ereg() is deprecated in /home/squtch/drupal-5.23/includes/file.inc on line 646.
  • : Function ereg() is deprecated in /home/squtch/drupal-5.23/includes/file.inc on line 646.
  • : Function ereg() is deprecated in /home/squtch/drupal-5.23/includes/file.inc on line 646.
  • : Function ereg() is deprecated in /home/squtch/drupal-5.23/includes/file.inc on line 646.
  • : Function ereg() is deprecated in /home/squtch/drupal-5.23/includes/file.inc on line 646.
  • : Function ereg() is deprecated in /home/squtch/drupal-5.23/includes/file.inc on line 646.
  • : Function ereg() is deprecated in /home/squtch/drupal-5.23/includes/file.inc on line 646.
  • : Function ereg() is deprecated in /home/squtch/drupal-5.23/includes/file.inc on line 646.
  • : Function ereg() is deprecated in /home/squtch/drupal-5.23/includes/file.inc on line 646.
  • : Function ereg() is deprecated in /home/squtch/drupal-5.23/includes/file.inc on line 646.
  • : Function ereg() is deprecated in /home/squtch/drupal-5.23/includes/file.inc on line 646.
  • : Function ereg() is deprecated in /home/squtch/drupal-5.23/includes/file.inc on line 646.
  • : preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/squtch/drupal-5.23/includes/unicode.inc on line 311.
  • : preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/squtch/drupal-5.23/includes/unicode.inc on line 311.

When putting links on one of your pages to other pages on the same site, there are three basic choices:

  1. Full URL - This is the protocol + domain + path version where there is absolutely no mistaking where you are intending to point. An example of this would be http://www.example.com/directory/file.html.
  2. Absolute Path - This version does not include the domain name, but does have the entire path name from the root directory down. This version always starts with a "/" instead of a directory name, filename or a ".". And example would be /directory.file.html
  3. Relative Path - This version is generally the shortest and points to the target relative to the current position in the directory tree. If you are in /dir1/file.html and you have a link to "../file1.html" you would move up one directory and open /file1.html. If you linke to "dir2/file2.html" you will go down one level to /dir1/dir2/file2.html because it will look for dir2 relative to your current location in dir1. Link to a file "file3.html" and you will end up at /dir1/file3.html.
  4. Go to any of the webmaster BBSs and within a couple of weeks you will see a battle waging about which way is the best way to link. There are perfectly valid reasons for using any of the above methods. If you are serving up downright huge pages, then you have a darn good reason for choosing the shortest URLs you can get away with.

    Personally, I think that going with full URLs is your safest and best choice, especially with a new site.

    To start with, the more complete your URL, the less likely you are to screw it up without noticing. Errors in encoding can lead to different results in different browsers and search engine spiders. I have seen IE handle an error one way, Firefox another and Opera totally different than the first two.

    One of the first steps in launching your site is getting it completely spidered by the big three search engines. With a small to medium sized site, Yahoo and MSN should spider them relatively quickly, but I have found that Google seems to crawl full URLs on a new site than they faster than they crawl those that are only linked to with relative URLs.

    Aside form the big three search engines, I have found some search engines have problems with relative paths. To be more precise, Alexa seems to send sites with relative paths all sorts of wacky requests. If you care about search engines other than the big three, then you will want to go with full URLs.

    By using a full URL you also gain an advantage when it comes to canonical issues with Google. If some people link to your site with "http://example.com" and others link to it as "http://www.example.com" then you can have the problem wo google not recognising them as the same page. But if all your internal pages link with the "www" as part of the URL, it will help the search engine to understand that they are the same page, and even if they don't, the pages with "www" will gain the most importance.

    And finally, if someone swipes a copy of your site, it will be more work for them to clean up those absolute URLs, and they might leave some pointing back to your site. If they leave some of those URLs in, then you will see them showing up in your logs, which can tip you off to the copies. Those URLs will also be proof positive that they copied those files from your site.

    Certainly, if you are not having any problems with your site as it is currently set up, then there isn't much point in changing things. I just think that it is a good practice to go with full URLs from the start to aboid possible problems. Your mileage may vary.