Which URL is Right?

Following Andrews’s look at good hyperlink text last week, Steve wrote in to ask about the other side of the hyperlink equation: URLs.

Steve writes,

How about starting a crusade to standardize URLs?




Good question, Steve! First of all, these pairs are equivalent:

  • http://www.example.com
  • http://www.example.com/
  • http://example.com
  • http://example.com/

The trailing ‘/’ is implied if there is no path specified, so you can use either form freely. In the same way, the port number (80) is implied in most URLs, but you could quite correctly spell it out:

  • http://www.example.com:80
  • http://www.example.com:80/
  • http://example.com:80
  • http://example.com:80/

Best practice is to leave off the port number when it is 80, of course. As for whether to leave off the path when it is ‘/’, that’s a matter of personal preference. Some will argue that leaving off the ‘/’ saves a byte on an Internet crowded with bytes. Others will argue that including the ‘/’ makes it clear to readers that you’re referring to the home page of the site in question, as opposed to the site as a whole.

Next we have the question of whether to include a ‘www.’ at the start of the hostname. This is a rather controversial subject that we covered at length in Tech Times #184. In short, including the ‘www.’ is a nod to Web tradition, whereas leaving it off is bowing to current Web fashion.

Strictly speaking, neither is incorrect. Pick whichever suits you best. The important thing is to make sure that the other form automatically redirects to the form you have chosen. If your server answers to both forms without redirection, search engines will see your site as two separate sites (one with the ‘www.’ and one without), each of which will have a lower search engine ranking than if your site had a single, authoritative hostname.

You can find instructions to set up your web server to redirect to your preferred hostname at the no-www advocacy site. From its name you can tell which URL style it prefers!

As for the URL of the home page (/, /index, or /index.html), again that is largely a matter of personal style, and again the key is to choose one and make sure that the others either redirect to your preferred form, or display a 404 error page. This ensures that search engines don’t mistake them for multiple copies of the same page at different addresses.

How do you like your URLs? Trailing slash or no? ‘www.’ or no ‘www.’? Let me know by leaving a comment!