3

For my web page, I have a .htaccess document which looks like this

<Files .htaccess>
order allow,deny
deny from all
</Files>

ErrorDocument 404 /websites/404/index.php

Now as far as I understand it you can include further ErrorDocument by just adding another line. For example

<Files .htaccess>
order allow,deny
deny from all
</Files>

ErrorDocument 404 /websites/404/index.php
ErrorDocument 503 /websites/maintenance/index.php

However, when I try to add a page for HTTP 451 using the following line of code ErrorDocument 451 /websites/451/index.phpand I reload my page I get a Server error! Error 500. I later found out this was because XAMPP was no longer picking up my folder with the .htaccess file in and the error could only be resolved by removing the ErrorDocument for error 451. What is causing this and how can I fix it?


Note
I also found that this happens for error 418: I'm a teapot as well


Edit
Just to include a little more information about the software I am using. I am using
  • XAMPP Control Panel v3.2.2
  • Apache 2.4.17 - This is the version which comes with XAMPP
YakovL
  • 7,557
  • 12
  • 62
  • 102
Dan
  • 7,286
  • 6
  • 49
  • 114

2 Answers2

6

Even though there are a lot of HTTP status codes (which are officially maintained by the IANA), not all webservers support all of these. As of Apache 2.4, the status codes 418 and 451 are not supported and silently converted to error 500 by Apache.

The latest additions of supported status codes in Apache 2.4 are 414 and 501 and a crash prevention for 400 (from Apache 2.4 change log):

core: Support custom ErrorDocuments for HTTP 501 and 414 status codes. PR 57167 [Edward Lu ]

core: Prevent a server crash in case of an invalid CONNECT request with a custom error page for status code 400 that uses server side includes. PR 58929 [Ruediger Pluem]

See the list of supported HTTP status codes (as of Apache 2.4.4).

See an older bug (filed against 2.2) regarding remapping of custom status codes to 500 errors.

See this previous question regarding a similar problem (but also with Apache 2.2).

Community
  • 1
  • 1
Paul
  • 8,974
  • 3
  • 28
  • 48
  • HTTP 451 support was added to Apache in 2016 although I can't tell the exact version number where support was added https://bz.apache.org/bugzilla/show_bug.cgi?id=58985 – Displayname71 Nov 06 '22 at 04:22
0

From your link to Wikipedia it states:

It (451) was approved by the IESG on December 18, 2015.[8] It was published as RFC 7725 in February 2016.

The 451 status might be recent enough that Apache (or other vendors which mod_rewrite relies on) haven't included support for the status code yet. There's a June 2016 bug report with Red Hat Enterprise - httpd-2.4.6-40 for example that looks to be still open: https://bugzilla.redhat.com/show_bug.cgi?id=1343582

William Isted
  • 11,641
  • 4
  • 30
  • 45