Can . (period) be part of the path part of an URL?

三世轮回 提交于 2019-11-27 21:31:30

问题


Is the following URL valid?

http://www.example.com/module.php/lib/lib.php

According to http://tools.ietf.org/html/rfc1738 section the hpath element of an URL can not contain a '.' (period). There is in the above case a '.' after "module" which is not allowed according to RFC1738.

Am I reading the RFC wrong or is this RFC succeed by another RFC? Some other RFC's allows '.' in URLs (http://tools.ietf.org/html/rfc1808).


回答1:


I don't see where RFC1738 disallows periods (.) in URLs. Here are some excerpts from there:

hpath          = hsegment *[ "/" hsegment ]
hsegment       = *[ uchar | ";" | ":" | "@" | "&" | "=" ]
uchar          = unreserved | escape
unreserved     = alpha | digit | safe | extra
safe           = "$" | "-" | "_" | "." | "+"

So the answer to your question is: Yes, http://www.example.com/module.php/lib/lib.php is a valid URL.




回答2:


Periods are allowed. See section "2.3 Unreserved Characters" in this document: http://tools.ietf.org/html/rfc3986

"Characters that are allowed in a URI but do not have a reserved purpose are called unreserved. These include uppercase and lowercase letters, decimal digits, hyphen, period, underscore, and tilde".




回答3:


Nothing wrong with a period in a url. If you look at the makeup in the grammar in the link you provided a period is mentioned via the 'safe' group, which is included via uchar a

Ignore my answer, Adams is better



来源:https://stackoverflow.com/questions/7555553/can-period-be-part-of-the-path-part-of-an-url

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!