可以在网址中使用方括号或括号吗? [英] Is it ok to have brackets or parenthesis in URL?

查看:119
本文介绍了可以在网址中使用方括号或括号吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为我的AdWord广告系列生成了网址,某些Campangin名称的括号内有() [] 括号.样本网址看起来像这样

Im generating URLs for my AdWord campaigns and some campangin names have brackets in them ( ) and [ ] brackets. And a sample url looks likes this

http://www.website.com/?utm_source=google%5BB%2B%5D&utm_medium=cpc&utm_content=google_ad(B)&utm_campaign=product

这样可以吗?

推荐答案

在URL的查询部分(即?"之后的部分)中可以使用括号()".可以(但不是必须)对它们进行%编码,例如%28"和%29".

Parentheses "()" may be used as such in the query part of URL (i.e., the part after "?"). It is allowable, but not necessary, to %-encode them, as "%28" and "%29".

在查询部分中,括号"[]"应进行%编码,分别为%5B"和%5D".

Brackets "[]" shall be %-encoded, as "%5B" and "%5D", in the query part.

这样正确构成了示例URL,它是www.website.com实际存在的真实URL(请使用www.example.com作为虚拟域名,保证不存在).

The sample URL, which is a real URL as www.website.com actually exists (please use www.example.com as a dummy domain name, it is guaranteed to not exist), is thus correctly formed.

URL语法的一般规则在Internet标准STD 66中定义,该标准当前为 RFC 3986.它的附录A指定了字符规则,将括号列为"sub-delims"组,允许在查询部分中不进行%编码,但括号中的列则属于"gen-delims",应进行%编码.

The general rules for URL syntax are defined in Internet-standard STD 66, which is currently RFC 3986. Its Appendix A specifies the rules for characters, listing parentheses as belonging to the "sub-delims" group which is allowed without %-encoding in the query part but the brackets as belonging to "gen-delims" which shall be %-encoded.

这篇关于可以在网址中使用方括号或括号吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆