2

When there are spaces in a URL like

http://example.com/this is not url enocoded

it is obvious, that the URL will end up as

http://example.com/this%20is%20not%20url%20encoded

When and what will encode my URL?

  • Should links that I create to my URL be encoded in my HTML documents?
  • Does the browser do the encoding?
  • Does the server do the encoding?
2

Browsers will automatically encode URL's with spaces, assuming you have linked to the file properly.

Create a file on your server called test one.html link to it or simply load it directly in your browser using spaces in the URL bar. http://www.example.com/test one.html

It will become test%20one.html

It's not and ideal way of naming or linking to files but the browser will handle it just fine. If you have a lot of static files with spaces which you'd like to update to - dashes or hyphens. A great program to use is

http://www.bulkrenameutility.co.uk/Main_Intro.php

2

While browsers can automatically make the conversion from spaces to encoded versions, you should ensure that your server software outputs correctly encoded URLs.

Not all browsers / bots can do the encoding properly.

If you do not have a CMS, you should encode the URLs in your HTML content.

Best way is to restrict to not using URLs with special characters.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.