Is that a URL, URI, or URN?

Today I learned that I have been using the term URI (Uniform Resource Identifier) incorrectly. Apparently so many people misuse the acronyms URL, URI, and URL that there is entire blog posts out there trying to clear up the confusion.

So why is this random piece of knowledge so important I felt like doing a blog post on it? Well put simply I believe that it’s important to try and learn all you can about your trade even those random snippets of knowledge that honestly most people will never need to know. Unless you deal with web based software or technologies that deal directly with internet protocols you probably will never care what people call that magic string of characters that takes you across the internet.

Keeping that explanation in mind you should stop reading this post and have a glance at Daniel Miessler’s The Difference Between URLs and URIs. In case of link rot I have copied the image from his post below since it does a good job at summarizing what he talks about:

Now for my career in computer programming (as well as attempts at teaching, software engineering, and breaking things with code) its important to me that I understand what I’m doing. The way I look at it is its a domino effect, if I don’t learn something or if I learn something incorrectly it negatively effects my work and in general my knowledge of a particular topic. I am not advocating for perfection though! Mistakes happen and are great learning opportunities and no one can be expected to remember everything they ever learn, but you can choose like I did to just straight up not learn. Case in point is this simple PHP code that I copied from somewhere years ago and never bothered to truly dissect because it worked and fit my needs at the time:

From some further research particularly the PHP manual on parse_url() I now know my code should probably be using scheme or protocol instead of URI:

From Daniel Miessler’s post I learned that the protocol, or scheme as I choose to name it in my PHP code above, is what sets URLs apart from URIs. What I choose to name the variable is not the point of this post though. The point that I’m trying to make is that combining the knowledge from Daniel Miessler’s post with what I learned from the PHP manual has helped me now have a general understanding of all of the following:

  • scheme (protocol)
  • host
  • port
  • usernames and passwords (in URLs)
  • path
  • query (stuff you see after a ? in URLs sometimes)
  • fragments (the stuff you see after a # in the URL sometimes)

Well I already knew some of these things as well as their various names across other programming languages, I now have a more complete knowledge of not just URLs but the protocols and standards behind them. Had I known this stuff earlier it would have helped me solve a programming issue I ran into today a lot faster and as you might imagine knowing the actual terminology of what your doing makes finding solutions and getting help so much easier! As any experienced programmer out there knows though there will be many more study and troubleshooting sessions like this to come.

Leave a Reply