0

My question is similar to this question, but for Apache. I handle all HTTP errors myself using a custom error handling page.

I noticed today that when I get a 414 error, I get the default Apache 414 error page:

Request-URI Too Long
The requested URL's length exceeds the capacity limit for this server.
Apache/2.4.25 (Debian) Server at host Port 80

I've been trying to read up on how to fix this but I've not gotten very far. However, it seems that what's happening is Apache is not even letting the 414 request get to my site, so my .htaccess file isn't getting read.

How can I force Apache to pass 414 error requests to my site?? I need to be able to handle the error myself.

I've not encountered this weird issue with any other kind of error, apart from a 414. 404, 403, 401, etc. all work fine - just not this one - so it's not that my error handling isn't working in general. I also have a 414 match in my .htaccess

InterLinked
  • 147
  • 1
  • 7

1 Answers1

1

Do not put it inside a directory level .htaccess.

.htaccess files provide a way to make configuration changes on a per-directory basis.

You should avoid using .htaccess files completely if you have access to httpd main server config file. Using .htaccess files slows down your Apache http server. Any directive that you can include in a .htaccess file is better set in a Directory block, as it will have the same effect with better performance.

Instead, put it on your global configuration as the error 414 is fired before getting inside Directory nor even VirtualHost contexts.

Esa Jokinen
  • 43,252
  • 2
  • 75
  • 122
  • There are multiple websites on this server - it's a shared server that I and another guy jointly use. Yes, I have full access to the server, but it's not just my websites on there. Other websites may want to handle them differently. – InterLinked Apr 22 '20 at 17:51
  • That's impossible. In `414` situation the server doesn't even see `Host` header, as explained in the linked answer. – Esa Jokinen Apr 22 '20 at 17:52
  • Can I serve a custom error by doing this at the server level still? This is not desirable, as all websites on the server would share one 414 error page, but I guess it's better than having no custom error page at all... (additionally, might it be possible to rewrite the 414 errors at the server level to pass it on to the site?) – InterLinked Apr 22 '20 at 17:55
  • How would the server know which site it is? And there's no really use for the custom error page anyway: no user will ever see it, as it's not within typical use cases. – Esa Jokinen Apr 22 '20 at 18:05
  • Standard syntax in apache2.works. Error page doesn't work properly because all the paths are broken since it's relative to a different path. I ended up putting a static html file in the server root. Not ideal, but I guess that's as good as it'll get. – InterLinked Apr 22 '20 at 18:12
  • I'm curious - also - are there any errors besides a 414 error that are handled at the server level and cannot be handled by the website? – InterLinked Apr 22 '20 at 18:14