禁止HTTP错误403:含义和解决方法

Receiving any error code while online can be a frustrating experience. While we've become accustomed to 404 Not Found pages, even to the extent that it's become common to see cute placeholder pages to entertain us whenever we get lost, one of the more puzzling errors is the 403: Forbidden response.

在线接收任何错误代码可能会令人沮丧。 尽管我们已经习惯了404 Not Found页面,但即使到了迷路时 ,看到可爱的占位符页面来招待我们的程度也变得很普遍,但更令人困惑的错误之一是403:禁止响应。

这是什么意思? (What does it mean?)

Simply put: the server has determined that you are not allowed access to the thing you've requested.

简而言之:服务器已确定不允许您访问所请求的内容。

According to RFC 7231:

根据RFC 7231

The 403 (Forbidden) status code indicates that the server understood the request but refuses to authorize it...If authentication credentials were provided in the request, the server considers them insufficient to grant access.
403(禁止)状态代码表示服务器理解了请求但拒绝对其进行授权...如果在请求中提供了身份验证凭据,则服务器认为它们不足以授予访问权限。

The 403 response belongs to the 4xx range of HTTP responses: Client errors. This means either you, or your browser, did something wrong.

403响应属于HTTP响应的4xx范围:客户端错误。 这意味着您或您的浏览器做错了什么。

If you encounter this it usually means that you have already authenticated yourself with the server, i.e. you've logged in, but the resource you have requested expects someone with higher privileges.

如果遇到这种情况,通常意味着您已经通过服务器进行了身份验证,即您已经登录,但是所请求的资源期望具有更高特权的人。

Most commonly, you might be logged in as a standard user, but you are attempting to access an admin page.

最常见的情况是,您可能以标准用户身份登录,但是您正在尝试访问管理页面。

您如何解决? (How do you fix it?)

As a user without access to the server, you really only have a few options:

作为无法访问服务器的用户,您实际上只有几个选择:

使用更合适的帐户进行身份验证 (Authenticate yourself with a more appropriate account)

Again, according to RFC 7231:

同样,根据RFC 7231

If authentication credentials were provided in the request, the server considers them insufficient to grant access.  The client SHOULD NOT automatically repeat the request with the same credentials.  The client MAY repeat the request with new or different credentials.
如果请求中提供了身份验证凭据,则服务器认为它们不足以授予访问权限。 客户端不应使用相同的凭据自动重复请求。 客户端可以用新的或不同的证书重复请求。

This is the only one that gives you any immediate power to rectify the issue.

这是唯一可以立即为您解决问题的功能。

If you have multiple accounts for a site and you are attempting to do something you can usually do, but this time are forbidden from doing, this is the option you should try. Log in with your other account.

如果您有一个站点多个帐户,并且尝试执行通常可以执行的操作,但是这次禁止这样做,则应尝试此选项。 使用您的其他帐户登录。

You may find that this option also requires clearing your cache or cookies, just in case logging in as another user doesn't sufficiently flush the previous authentication tokens. But this is usually unnecessary.

您可能会发现,此选项还需要清除缓存或cookie,以防万一由于其他用户登录而导致刷新身份验证令牌失败。 但这通常是不必要的。

As a desperate move, you could also try disabling browser extensions that might be interfering with your use of the site. However, this is unlikely, since a 403 implies you are authenticated, but not authorized.

作为一个绝望的举动,您也可以尝试禁用可能会干扰您使用该网站的浏览器扩展。 但是,这不太可能,因为403表示您已通过身份验证,但未获得授权。

通知网站所有者,否则您将返回403 (Notify the site owner that a 403 is being returned when you'd expect otherwise)

If you fully expect that you should be able to access the resource in question, but you are still seeing this error, it is wise to let the team behind the site know - this could be an error on their part.

如果您完全希望能够访问有问题的资源,但是仍然看到此错误,那么明智的做法是让站点背后的团队知道-这可能是他们的错误。

Once more from RFC 7231:

再次来自RFC 7231

However, a request might be forbidden for reasons unrelated to the credentials.
但是,出于与凭据无关的原因,可能会禁止请求。

A common cause for this happening unintentionally can be that a server uses allow- or deny-lists for particular IP addresses or geographical regions.

意外发生的常见原因可能是服务器使用特定IP地址或地理区域的允许列表或拒绝列表。

They might have a good reason for blocking your access outside of their strictly defined parameters, but it could also just be an oversight.

他们可能有充分的理由在严格定义的参数之外阻止您的访问,但这也可能是一个疏忽。

放弃。 (Give up.)

Maybe you just aren't supposed to be able to access that resource. It happens. It's a big internet and it's reasonable to expect that there are some areas off limits to you personally.

也许您不应该能够访问该资源。 它发生了。 这是一个庞大的互联网,可以合理地预期某些区域对您本人来说是无法进入的。

You could visit http.cat instead while ruminating on why your original request was forbidden.

您可以反省一下http.cat,同时仔细考虑为什么禁止您的原始请求。



As a reader of freeCodeCamp News, you are almost certainly not forbidden from following @JacksonBates on Twitter for more tech and programming related content.

作为freeCodeCamp新闻的读者,几乎可以肯定,您不禁止在Twitter上关注@JacksonBates以获取更多与技术和编程相关的内容。

翻译自: https://www.freecodecamp.org/news/http-error-403-forbidden-what-it-means-and-how-to-fix-it/

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值