views:

53

answers:

8

i have a url in this format:

http://www.example.com/manchester united

note the space between manchester and united, is this bad practice, or is it perfectly fine, i just wanted to before i proceed, thanks

A: 

I believe spaces in URLS are replaced with a %20 sign by many browsers.

Slider345
thier not they display a proper space.
getaway
A: 

Can do that, but apparently it's bad style.

See the following: http://www.blooberry.com/indexdot/html/topics/urlencoding.htm

MStodd
@MStodd It is possible to have a space in a URL. The browser encodes it for transmission and the server decodes it. Browsers vary as to whether or not they display the encoded or raw version of the URL. It's technically possible, but it's definitely bad style.
Andrew Cooper
+2  A: 

It's bad practice not only because browsers are required to turn the space into a %20 and thus obfuscate your users' address bars, but because it would be difficult to communicate the url to anyone. Furthermore, what about all of those "find links in text" regexes that are around stack overflow? You effectively break them all!

Mike Axiak
+2  A: 

It will be replaced in the address bar as http://www.example.com/manchester%20united, which I personally think if far uglier than the alternative http://www.example.com/manchester_united.

David Watson
This depends on the browser. Some browsers leave the space there in the address bar. It can still make it difficult to read the URL in some contexts.
Andrew Cooper
A: 

you will need to add %20 instead of the space, however the browser will do it for you, I would rather not have any spaces in the URI

bashmohandes
A: 

Technically this will work. The browser will replace the space with a %20, and the server will translate it back.

But ... it's not generally a good idea because it can lead to ambiguity, or difficulty in communicating the URL to others, particularly in an advertising setting where you're expecting someone to type in a URL they've seen in print.

Andrew Cooper
A: 

Maybe a question for: http://webmasters.stackexchange.com/

But...

If you enter than into a browser, it will add %20 between manchester and united. Technically you should do this in your HTML page but most modern browsers can handle this. Common practice is to split them out with a hyphen i.e. http://www.example.com/manchester-united.

Look at the URL of this question for an example of this in action.

BradB
+2  A: 

The space is not a valid character in URIs; you have to replace it with %20. It may also be considered bad practice. Replacing the space with -, + or _ is preferable; it is both “prettier” and doesn't require escaping of the URI.

Most browsers will still try to parse URIs with a space; but that's highly ambiguous.

You