能够 .(句点)是URL的路径部分的一部分?

Mof*_*ffe 31 url rfc

以下网址有效吗?

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

根据http://tools.ietf.org/html/rfc1738部分,URL的hpath元素不能包含'.'.(期).在上面的例子中有'.' 在根据RFC1738不允许的"模块"之后.

我是在读错了RFC还是这个RFC被另一个RFC取得了成功?其他一些RFC允许'.' 在URL(http://tools.ietf.org/html/rfc1808)中.

Ada*_*kin 40

我没有看到RFC1738在URL中禁止句点(.).以下是一些摘录:

hpath          = hsegment *[ "/" hsegment ]
hsegment       = *[ uchar | ";" | ":" | "@" | "&" | "=" ]
uchar          = unreserved | escape
unreserved     = alpha | digit | safe | extra
safe           = "$" | "-" | "_" | "." | "+"
Run Code Online (Sandbox Code Playgroud)

所以你的问题的答案是:是的,http://www.example.com/module.php/lib/lib.php是一个有效的URL.


spe*_*ane 13

正如其他人所指出的,URL 中允许使用句点,但要小心。如果在 URL 路径的一部分中使用单句点或双句点,浏览器会将其视为路径的更改,您可能无法获得所需的行为。

例如:

  • www.example.com/foo/./ 重定向到 www.example.com/foo/
  • www.example.com/foo/../ 重定向到 www.example.com/

而以下不会重定向:

  • www.example.com/foo/bar.biz/
  • www.example.com/foo/..biz/
  • www.example.com/foo/biz../


Gre*_*ett 8

期间是允许的.请参阅本文档中的"2.3未保留字符"部分:http: //tools.ietf.org/html/rfc3986

"URI中允许但没有保留目的的字符称为未保留字符.这些字符包括大写和小写字母,十进制数字,连字符,句点,下划线和波浪号".