What Is URL Encoding?

Navigation

Sponsors

Save this to Del.icio.us

URL Encoding

What Is URL Encoding?

"URL Encoding", otherwise known as "Percent Encoding" is a technique used to encode certain characters / strings within the URL. This can be handy when sending information, such as a product information within the URL.

When Do We Need URL Encoding?

An example of where "URL Encoding" is required can be seen in such things as Digg buttons. Here is a little snippet from the code used to submit stories to Digg from external sites:

...www.digg.com/submit?phase=2&url=example.com&title=TITLE&bodytext=...

This URL contains a lot of information for the server-side script to process. If you have any existing knowledge about server-side programming languages such as PHP, you will know that the "?" after "submit" seperates the location of the file being run (www.digg.com/submit), and the variables ("phase", "url", "title" etc...).

You have probably noticed by know that the variables are presented in pairs. For example the variable "phase" should equal "2", the "url" should be "example.com" etc... It's pretty self-explanatory really.

The problem comes when the variable are strings that contain more complex characters. For example what if we wanted to have "My Dog's Video Blog - Funny!!!" as the variable "title". You may say why not just add it like you have the others and do this:

...com&title=My Dog's Video Blog - Funny!!!&bodytext=...

This is in fact incorrect and will not work. "URL Encoding", or "Percentage Encoding" solves this problem by giving a 3 character URL encoded value for characters such as "'" and "!". The first character is always a "%", hence it's name "Percentage Encoding".

How Do I URL Encode?

There are various tools available online that will help you do this, such as our JavaScript URL Encoder / Decoder. Simply type in what you want to encode / decode and click on the appropriate button.

Example of Correct URL Encoding

Here is the correct URL encoded version of the previous example where we were trying to use the value of "My Dog's Video Blog - Funny!!!" for the variable "title":

...title=My%20Dog%27s%20Video%20Blog%20-%20Funny%21%21%21&bodytext=...


[ Back to The New Webmaster's Resource Page ]


Forums | Search | Donate | Links | Contact | Templates | Privacy Policy
Copyright © 2017 SiteToolCenter.com

Website Design

Best Viewed With Mozilla FireFox