By using this site you agree to the use of cookies.

Learn more

Share via:

HTTP 403 Forbidden

The HTTP 403 status code indicatss that the server understood the request, but is refusing to fulfill it. Learn more in this tutorial.

Edited: 2017-06-19 14:48

The HTTP 403 Forbidden error response is used when the server understood the request, but is refusing to fulfill it for some reason. This error is often encountered when entering a wrong username or password on a website.

Sometimes you may want to show a soft 403 Forbidden error, so that automated spam-bots gets confused. Soft errors will usually just send a 200 OK response instead of the real error – this is done to break certain bots and hacker tools.

To send a 403 response from PHP, you can use the header function like this:

$Error_Page_Content = '';
header('HTTP/1.0 403 Forbidden');
echo $Error_Page_Content;

Note. If you want to deliver a custom error page, then it should be outputted after sending the headers. You should fill $Error_Page_Content with your own HTML.

More

  1. Creating a Custom Error Page – How to create a custom error page
  2. HTTP Response Codes – A list of HTTP Response Codes
  3. PHP Header – How to deliver status codes with PHP