HTTP 403禁止状态代码和修复错误

HTTP protocol uses HTTP status codes in order to provide information about the requests. There are different types of status codes like 100, 200, 300, 400, etc. All of them have different meanings and subcodes like 403. In this tutorial, we will examine the 403 Forbidden Error Code .

HTTP协议使用HTTP状态代码以提供有关请求的信息。 状态码有不同类型,例如100、200、300、400等。它们都有不同的含义和子代码,例如403。在本教程中,我们将研究403 Forbidden Error Code

范例回应 (Example Response)

Here is some example response about HTTP 403 Forbidden. This code is compatible with all major browsers.

这是关于HTTP 403 Forbidden的一些示例响应。 该代码与所有主流浏览器兼容。

HTTP/1.1 403 Forbidden 
Date: Wed, 21 Oct 2015 07:28:00 GMT

AND other variations may like below.

AND其他变化可能如下所示。

403 Forbidden
HTTP 403
Forbidden: You don't have permission to access [directory] on this server
Forbidden
Error 403
HTTP Error 403.14 - Forbidden
Error 403 - Forbidden
HTTP Error 403 - Forbidden

403禁止的意思 (403 Forbidden Meaning)

Web servers are used to serve server resources in different ways. These resources are shared with a URI where it refers to the resource. In some cases, some resources may be not provided to the request. This is generally applied with resource restriction with 403 Forbidden . Or the access may require some authentication to the resource.

Web服务器用于以不同的方式提供服务器资源。 这些资源与URI共享,URI引用该资源。 在某些情况下,某些资源可能没有提供给请求。 这通常适用于403 Forbidden资源限制。 否则,访问可能需要对资源进行某种身份验证。

根据编程语言和框架的403代码参考 (403 Code References According To Programming Languages and Framework)

There are different programming languages and frameworks in order to serve the HTTP protocol. They generally provide some constant as easy to respond with HTTP 403 Forbidden code. Here are some of the popular them.

为了服务于HTTP协议,有不同的编程语言和框架。 它们通常提供一些易于使用HTTP 403 Forbidden代码响应的常量。 以下是一些受欢迎的商品。

  • Ruby On Rails HTTP 403 Forbidden  :forbidden

    Ruby On Rails HTTP 403禁止使用:forbidden

  • Go HTTP 403 Forbidden http.StatusForbidden

    转到HTTP 403禁止http.StatusForbidden

  • Symfony HTTP 403 Forbidden Reponse::HTTP_FORBIDDEN

    Symfony HTTP 403禁止Reponse::HTTP_FORBIDDEN

  • Python2 HTTP 403 Forbidden httplib.FORBIDDEN

    Python2 HTTP 403禁止使用httplib.FORBIDDEN

  • Python3 HTTP 403 Forbidden http.client.FORBIDDEN

    Python3 HTTP 403禁止使用http.client.FORBIDDEN

  • Python3.5+ HTTP 403 Forbidden http.HTTPStatus.FORBIDDEN

    Python3.5 + HTTP 403禁止使用http.HTTPStatus.FORBIDDEN

客户端的403禁止错误解决方案 (403 Forbidden Error Solution From Client Side)

There are different ways to solve this error. We will learn generic ways to solve this. But as you know there are different web servers like Apache, IIS, Tomcat, Nginx, etc which provides a different mechanism to solve this problem.

有多种方法可以解决此错误。 我们将学习解决此问题的通用方法。 但是您知道,有不同的Web服务器,例如Apache,IIS,Tomcat,Nginx等,它们提供了解决此问题的不同机制。

  1. Check URL . We may try to access a URL that is incorrect or does not exist.

    Check URL 。 我们可能会尝试访问不正确或不存在的URL。

  2. Clear Browser Cache. HTTP protocol generally tries to look local cache to get resources faster. We need clear this cache which will get resources from remote servers without looking cache.

    Clear Browser Cache 。 HTTP协议通常尝试查找本地缓存以更快地获取资源。 我们需要清除此缓存,这将在不查找缓存的情况下从远程服务器获取资源。

  3. Login or Authenticate Web Site . We may need to login to access given resources. We can use HTTP basic authentication or similar ways.

    Login or Authenticate Web Site 。 我们可能需要登录才能访问给定的资源。 我们可以使用HTTP基本身份验证或类似方式。

  4. Clear Browser Cookies . Cookies are generally used to provide login and session information. Old cookies may provide session related problems so clearing browser cookies will solve this issue.

    Clear Browser Cookies 。 Cookies通常用于提供登录和会话信息。 旧的cookie可能会提供与会话相关的问题,因此清除浏览器cookie将解决此问题。

LEARN MORE  How To Control Python For Loop with Break Statement?
了解更多信息如何使用Break语句控制Python For循环?

服务器端的403禁止错误解决方案 (403 Forbidden Error Solution From Server Side)

If we are the owner of the web server we have to look several cases in order to solve this issue.

如果我们是Web服务器的所有者,则必须查看几种情况以解决此问题。

  1. Empty httpdocs directory while navigating to the given URL or directory there may need some resources to match and present.  If there is no folder we have to create is in the web server or httpdocs directory.

    导航到给定的URL或目录时,请Empty httpdocs directory ,可能需要一些资源进行匹配和显示。 如果没有文件夹,我们必须在Web服务器或httpdocs目录中创建。

  2. No index page Index pages like index.html , index.asp or index.php is used to provide default content and resources. If they do not exist we should create them properly.

    No index page诸如index.htmlindex.aspindex.php类的索引页用于提供默认内容和资源。 如果不存在,则应正确创建它们。

  3. Permission and ownership errors Web server process or daemon will home some rights to read, write , execute local file system. If they are not set properly we will get HTTP 403 Forbidden error. We can use the following permissions for Linux systems.

    Permission and ownership errors Web服务器进程或守护程序将拥有读取,写入和执行本地文件系统的某些权限。 如果未正确设置它们,则会收到HTTP 403 Forbidden错误。 我们可以对Linux系统使用以下权限。

Folders and Directories: 755

Static Content and Regular Files: 644

Dynamic Content and Web Application Code: 700

For more information about permission look following chmod tutorial.

有关权限的更多信息,请参见chmod教程。

Linux Chmod Command Tutorial with Examples To Change Permission of Files and Folders

Linux Chmod命令教程,其中包含更改文件和文件夹权限的示例

翻译自: https://www.poftut.com/http-403-forbidden-status-code-and-fix-error/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值