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: 2019-11-23 07:07
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.
Send a 403 from PHP
To send a 403 response from PHP, you can use the header function like this:
$Error_Page_Content = '';
header('HTTP/1.1 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
- Creating a Custom Error Page – How to create a custom error page
- HTTP Response Codes – A list of HTTP Response Codes
- PHP Header – How to deliver status codes with PHP
Tell us what you think: