开发者

is this url unvalid and not good practice?

i have a url in this format:

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

note the space between manchester and united, is thi开发者_运维百科s bad practice, or is it perfectly fine, i just wanted to before i proceed, thanks


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.


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!


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.


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


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


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.


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.


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

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜