在URL中有括号可以吗? [英] Is it ok to have brackets in URL?

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

问题描述

为我的AdWord广告系列生成网址,并且一些广告系列名称中包含括号() [] 括号。并且一个示例url看起来像这样

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

这样好吗?

解决方案

圆括号()可以用于URL的查询部分(即?之后的部分) )。 % - 编码它们是允许的,但不是必需的,因为%28和%29。

括号[]应为% - 编码,在查询部分显示为%5B和%5D。



示例网址实际上存在于www.website.com请使用www.example.com作为虚拟域名,它保证不存在),因此可以正确形成。



URL语法的一般规则在互联网标准STD 66,目前是 RFC 3986 。其附录A规定了字符规则,列出括号为属于子界限组,在查询部分中不允许使用%-encoding,但括号属于应编码%的gen-delims。

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

Is this fine?

解决方案

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".

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

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.

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.

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

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