views:

10

answers:

2

I just tried the following URL: http://www.google.com/search?hl=en&q=http://www.yahoo.com/path/to/location on my browser, and it worked! What made it work? And why should one encode URLs other than substituting spaces with + or %20, etc.? That is, do I still need to encode my URLs even if I don't have any characters that's not allowed in a valid URL?

Thanks for your time.

+1  A: 

Browsers generally encode the url's automatically, and may or may not show it encoded. A PHP script may or may not encode it automatically... if it didn't it would lead to a URL parsing error or something.

TheAdamGaskins
+1  A: 

Your browser probably URL-endcoded the URL you typed before sending the request. You should be able to check this by inspecting the actual HTTP request. In Firefox, for example, you can do this with LiveHttpHeaders.

Peter Hilton