Dennis, I think you have misread the linked document. That limitation only applies to the "scheme" portion of the URL. In the case of WWW URLs, that is the "http".
The next section of the document goes on to say:
Thus, only alphanumerics, the special characters "$-_.+!*'(),", and reserved characters used for their reserved purposes may be used unencoded within a URL.
I'd personally use comma (,). However, plus (+) and dash (-) are both reasonable options as well.
BTW, that document also mentions that semi-colon (;) is reserved in some schemes.
"+" is to be interpreted as a space " " when the content-type is application/x-www-form-urlencoded (standard for HTML forms). This may be handled by your server software.
I prefer "!". It doesn't get URL encoded (at least not in Chrome) and it reserves "+" for use as a real space character in the typical case.
发布评论
评论(5)
丹尼斯,我认为你误读了链接文档。该限制仅适用于 URL 的“方案”部分。对于 WWW URL,即“http”。
该文件的下一部分继续说道:
我个人会使用逗号(,)。然而,加号 (+) 和破折号 (-) 也是合理的选择。
顺便说一句,该文档还提到分号(;)在某些方案中被保留。
Dennis, I think you have misread the linked document. That limitation only applies to the "scheme" portion of the URL. In the case of WWW URLs, that is the "http".
The next section of the document goes on to say:
I'd personally use comma (,). However, plus (+) and dash (-) are both reasonable options as well.
BTW, that document also mentions that semi-colon (;) is reserved in some schemes.
好吧,根据 RFC1738,有效的 URL 只能包含字母 a< /kbd>-z、加号 (+)、句号和连字符 (-)。
一般来说,我会用加号来分隔您的搜索区域。因此,您的网址将变为 http://www.example.com/list?seach_type=0&search_period=1&search_min=3000&search_max=21000&search_area=6855+7470+7700+..。
--编辑--
正如 GinoA 指出的,我误读了该文档。因此,“
$-_.+!*'(),
”在未编码 URL 中也是有效字符。不过,我仍然会使用+
符号。Well, according to RFC1738, valid URLs may only contain the letters a-z, the plus sign (+), period and hyphen (-).
Generally I would go with a plus to separate your search areas. So your URL would become http://www.example.com/list?seach_type=0&search_period=1&search_min=3000&search_max=21000&search_area=6855+7470+7700+...
--EDIT--
As GinoA pointed out I misread the document. Hence "
$-_.+!*'(),
" are valid characters too in an unencoded URL. I'd still go with the+
sign though.如果只有数字需要分隔,那么您有多种分隔符可供选择。例如,您可以选择任何字母。
也许一个空间是一个不错的选择。它将在 URL 中转换为
+
字符,因此比字母更易读。示例:
search_area=4000+5000+6000
If there are only numbers to separate, you have a large choice of separators. You can choose any letter for example.
Probably a space can be a good choice. It will be transformed into
+
character in the URL, so will be more readable than a letter.Example:
search_area=4000+5000+6000
我参加聚会很晚了,但是有效的查询字符串可以重复变量,因此
您也可以使用...而不是...
I'm very late to the party, but a valid query string can repeat variables so instead of...
...you could also use...
当内容类型为 application/x-www-form-urlencoded(HTML 表单的标准)时,“+”将被解释为空格“”。这可能由您的服务器软件处理。
我更喜欢“!”。它不会进行 URL 编码(至少在 Chrome 中不会),并且在典型情况下保留“+”用作真实的空格字符。
"+" is to be interpreted as a space " " when the content-type is application/x-www-form-urlencoded (standard for HTML forms). This may be handled by your server software.
I prefer "!". It doesn't get URL encoded (at least not in Chrome) and it reserves "+" for use as a real space character in the typical case.