Specification of the HTTP status code 421
The 421 Misdirected Request status code indicates that the request was directed at a server that is not able to produce a response. This can be sent by a server that is not configured to produce responses for the combination of scheme and authority that are included in the request URI.
Clients receiving a 421 Misdirected Request (Misdirected Request) response from a server MAY retry the request -- whether the request method is idempotent or not -- over a different connection. This is possible if a connection is reused (Section 9.1.1) or if an alternative service is selected [ALT-SVC].
This status code MUST NOT be generated by proxies.
A 421 Misdirected Request response is cacheable by default, i.e., unless otherwise indicated by the method definition or explicit cache controls (see Section 4.2.2 of [RFC7234]).
Source / Quote by: The 421 Misdirected Request HTTP Status Code is specified by section 9.1.2 of RFC7540.
HTTP-Protocol
How to throw a 421 statuscode with PHP?
To throw the HTTP status code 421 on a web page, the PHP function http_response_code can be used. The syntax is as follows: http_response_code(421) (PHP 5 >= 5.4.0, PHP 7, PHP 8)
Test the 421 HTTP status code
In order to be able to display the HTTP status code (in this case 421 Misdirected Request) and other information on the client side, the development console must be opened with F12. Afterwards you have to navigate to the tab "Network". Now you can open the page, in the network tab you should see the web page (example index.php). This must be selected and then the Herder section must be selected. Here the user will see the following result:
URL: https://http-statuscode.com/errorCodeExample.php?code=421
Status: 421 Misdirected Request
Those: Network
IP address: XX.XX.XX.XX
How to create a custom error page for the 421 status code
Apache Webserver
The web server "Apache" is one of the most popular web servers on the Internet. To create an own 421 Misdirected Request error page in "Apache", the following change must be made in the following file.
NGINX Webserver
Similar to the web server "Apache", "NGINX" is also widely used on the Internet. To create your own 421 Misdirected Request error page in "NGINX", the following change must be made in the following file.
location = /421.html {
root /usr/share/nginx/html;
internal;
}
Browser compatibility of the 421 status code
Chrome | no data |
Edge | no data |
Firefox | no data |
Opera | no data |
Safari | no data |
Chrome Android | no data |
Firefox for Android | no data |
Opera Android | no data |
Safari on iOS | no data |
Internet | no data |
WebView Android | no data |
Constants in programming languages
http.StatusMisdirectedRequest
Response::HTTP_MISDIRECTED_REQUEST
http.HTTPStatus.MISDIRECTED_REQUEST
:misdirected_request