Is a URL allowed to contain a space?

后端 未结 10 1403
慢半拍i
慢半拍i 2020-11-22 04:02

Is a URI (specifically an HTTP URL) allowed to contain one or more space characters? If a URL must be encoded, is + just a commonly followed convention

10条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-22 04:15

    URLs are defined in RFC 3986, though other RFCs are relevant as well but RFC 1738 is obsolete.

    They may not have spaces in them, along with many other characters. Since those forbidden characters often need to be represented somehow, there is a scheme for encoding them into a URL by translating them to their ASCII hexadecimal equivalent with a "%" prefix.

    Most programming languages/platforms provide functions for encoding and decoding URLs, though they may not properly adhere to the RFC standards. For example, I know that PHP does not.

提交回复
热议问题