编码的 URL 不起作用

发布于 2024-12-15 04:28:44 字数 323 浏览 2 评论 0 原文

我对编码的 URL 感到困惑。

例如,当我编写浏览器时:

stackoverflow.com/questions

我可以成功查看页面。

然而,当我写:

stackoverflow.com%2Fquestions

我无法查看。

由于 %2F 表示“/”,我想了解为什么这不能正常工作。

我想知道的原因是我得到了一个编码的 URL,但我不知道如何在收到该 URL 后立即对其进行解码,以免出现错误页面。

I am confused about encoded URLs.

For example, when I write my browser:

stackoverflow.com/questions

I can successfully view the page.

However, when I write:

stackoverflow.com%2Fquestions

I am unable to view.

Since %2F means "/", I want to understand why this does not work properly.

The reason why I want to find out is that I am getting an encoded URL and I don't know how I can decode that URL right after I receive it in order not to have an error page.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

柒夜笙歌凉 2024-12-22 04:28:44

/百分比编码保留字符之一。 URL 使用百分比编码保留字符来定义其语法。仅当这些字符在 URL 中不用于其特殊角色时,才需要对它们进行编码。

百分比编码保留字符:

!       *       '       (       )       ;       :       @       &       =       +       $       ,       /       ?       #       [       ]
%21     %2A     %27     %28     %29     %3B     %3A     %40     %26     %3D     %2B     %24     %2C     %2F     %3F     %23     %5B     %5D

The / is one of the percent-encoding reserved characters. URLs use percent-encoding reserved characters for defining their syntax. Only when these characters are not used in their special role inside a URL, they need to be encoded.

Percent-encoding reserved characters:

!       *       '       (       )       ;       :       @       &       =       +       $       ,       /       ?       #       [       ]
%21     %2A     %27     %28     %29     %3B     %3A     %40     %26     %3D     %2B     %24     %2C     %2F     %3F     %23     %5B     %5D
静待花开 2024-12-22 04:28:44

%2F 是一个URL 转义 /。这意味着,将 / 视为字符,而不是目录分隔符。

本质上,它正在寻找一个 stackoverflow.com/questions,而不是路径为questions<的域stackoverflow.com /代码>。

%2F is a URL escaped /. It means, treat / as a character, not a directory separator.

In essence, it is looking for a domain stackoverflow.com/questions, not the domain stackoverflow.com with the path questions.

不语却知心 2024-12-22 04:28:44

%2F 是当您想要在参数中包含 / 但不希望浏览器导航到不同的目录/路由时编写的内容。

因此,如果您将文件路径“root/subdirectory”作为查询字符串参数传递,则需要对其进行编码,如下所示:

http://www.testurl.com/page.php?path=root%2Fsubdirectory

而不是

http://www.testurl.com/page.php?path=root/subdirectory

%2F is what you write when you want to include a / in a parameter but don't want the browser to navigate to a different directory/route.

So if you had the file path 'root/subdirectory' passed as a querystring parameter, you would want to encode that like:

http://www.testurl.com/page.php?path=root%2Fsubdirectory

rather than

http://www.testurl.com/page.php?path=root/subdirectory

梦与时光遇 2024-12-22 04:28:44

URL 编码用于对来自 HTML 表单的字符串 URL 参数进行编码,其中包含特殊字符,如“/”。编写“stackoverflow.com%2Fquestions”是错误的,在这种情况下,“/”是 URL 本身的一部分,并且不得进行编码。

URL encoding is used e.g. for encoding a string URL parameter coming from an HTML form, which contains special characters, like '/'. Writing "stackoverflow.com%2Fquestions" is wrong, in this case the '/' is part of the URL itself, and must not be encoded.

李不 2024-12-22 04:28:44

%2F 是一个转义字符实体 - 这意味着它将包含在名称中,而不是字符 /,它表示目录层次结构,如 RFC 1630 第 8 页 中指定。

%2F is an escaped character entity - meaning it would be included in a name, rather than the character /, which denotes directory hierarchy, as specified in RFC 1630, page 8.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文