Url Encoding, It’s Not Just For Breakfast Anymore


I overheard two of my coworkers the other day talking about it and I actually ran into it myself the other day.  What am I talking about?  Its the common practice to use encode urls spaces as ‘-‘ when the standard says they should be ‘+’. 


For example:


http://www.engadget.com/2006/07/21/zune-what-we-know-think-we-know-and-dont-yet-know/


I think it is weird for this to happen.  Both the php urlencode function and the asp.net Server.UrlEncode function do not do this, they will convert spaces to ‘+’. 


So these begs the question of, why do they do this?


My best guess, just because it looks better.  I think search engines caught on and now will treat ‘-‘ as a space when they parse the urls for keywords, which is to bad for things that actually have a ‘-‘ in their keywords.


Comments (3)

  1. Richard says:

    I don’t know about PHP, but the ASP.NET Server.UrlEncode function replaces spaces with "+", not "-".

  2. MSDN Archive says:

    Typo, thanks for pointing it out!

  3. Rob Meyer says:

    I just watched a MIX08 presentation on Search Engine Optimization and one of the topics the presenter covered was formatting the urls for your product pages. He found three web stores selling Zunes and gave their URLs as examples…

    The first url looked like giberish and isn’t relevant

    http://store2.com/Microsoft_Zune_80_G2_Black/dp/B000J01IPI

    http://store3.com/Microsoft-Zune-80gb-Black/dp/B000J01IPI

    He said that using underscores was bad practice and Microsoft_Zune_80_G2_Black would be treated as a single string by the search engines. He said using hyphens ‘-‘ was the proper way to do it.

    But then, why is UrlEncode’s standard to use ‘+’ instead of ‘-‘?

    The presentation I was talking about was

    http://sessions.visitmix.com/?selectedSearch=T13 and if you want to fast forward to 40m30s you will see what I was referencing.