我可以在URL中使用at符号(@)吗? [英] Can I use an at symbol (@) inside URLs?

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

问题描述

作为用户的一部分,使用 @ 符号是否安全?例如,可能的网址为 http://example.com/@dave



现在,用户通常被称为@user,那么为什么不使用户页面@username?

解决方案



百分比编码...



您可以在HTTP URI路径中使用 @ 如果您百分比编码%40



许多浏览器仍会显示 @ ,但例如当您将URI复制并粘贴到文本文档中时,将会是%40



...也可以直接在HTTP URI路径中使用 @ ,而不是直接对其进行百分号编码。



请参阅URI的路径的语法。除了 segment-nz 中的字符,路径可以包含各种不相关的子句c> segment-nz-nc 设置。 cch> set,其定义为:

  pchar = unreserved / pct-encoded / sub-delims / :/@

如您所见, / code>是明确列出的。



segment-nz-nc c $ c> $ 字符显示:

  segment-nz- nc = 1 *(unreserved / pct-encoded / sub-delims /@)

这样的HTTP URI是完全有效的:

  http://example.com/@dave 



示例



第:




  • 链接

  • 复制和粘贴: http://en.wikipedia.org/wiki/%22@%22_%28album% 29



正如您所看到的,字符是百分比编码,但 @ 并直接使用 _


Is it safe to use an @ symbol as part of a user? For example, a possible URL would be http://example.com/@dave.

The idea is that, nowadays, users are commonly called "@user", so why not make the user page "@username"?

解决方案

Percent-encoded …

You can use the @ character in HTTP URI paths if you percent-encode it as %40.

Many browsers would display it still as @, but e.g. when you copy-and-paste the URI into a text document, it will be %40.

… but also directly

Instead of percent-encoding it, you may use @ directly in the HTTP URI path.

See the syntax for the path of an URI. Various unrelated clauses aside, the path may consist of characters in the segment, segment-nz, or segment-nz-nc set. segment and segment-nz consist of characters from the pchar set, which is defined as:

pchar = unreserved / pct-encoded / sub-delims / ":" / "@"

As you can see, the @ is listed explicitly.

The segment-nz-nc set also lists the @ character explicitly:

segment-nz-nc = 1*( unreserved / pct-encoded / sub-delims / "@" )

So, a HTTP URI like this is totally valid:

http://example.com/@dave

Example

Here is an example Wikipedia page:

  • link
  • copy-and-paste: http://en.wikipedia.org/wiki/%22@%22_%28album%29

As you can see, the ", (, and ) characters are percent-encoded, but the @ and the _ is used directly.

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

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