Reputation: 8990
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
Upvotes: 1
Views: 253
Reputation: 4746
Can do that, but apparently it's bad style.
See the following: http://www.blooberry.com/indexdot/html/topics/urlencoding.htm
Upvotes: -1
Reputation: 23774
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.
Upvotes: 2
Reputation: 977
Maybe a question for: https://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.
Upvotes: 0
Reputation: 32576
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.
Upvotes: 0
Reputation: 2376
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
Upvotes: 0
Reputation: 2039
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.
Upvotes: 2
Reputation: 11996
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!
Upvotes: 2
Reputation: 4748
I believe spaces in URLS are replaced with a %20 sign by many browsers.
Upvotes: 0