I am using errordocument to send 404 errors to a handler php page, but errordocument scrubs post data. How can I get around this?

StackOverflow https://stackoverflow.com/questions/17475631

  •  02-06-2022
  •  | 
  •  

Pregunta

Currently, I use errordocument 404 /handler.php so that I can have dynamic urls and analyze them all through that page. Now I find that I can not post data to a page because errordocument doesn't pass it through to handler.php. How can I use .htaccess to send all 404 errors to handler.php and accept post data?

¿Fue útil?

Solución

Replace ErrorDocument with RewriteRule (.*) /handler.php [L]

In your handler.php, you can then capture the REQUEST URI, POST data whatevere and then based on your logic, you can decide whether to return a HTTP/1.1 404 Page not found error or return normal response HTTP/1.1 200

Otros consejos

You can’t. This is what an MVC framework’s controller is for. If the page isn’t found based on the algorythems on the controller you throw an error page up initiated from the controller with a list of errors (usually from an array of 1 or more errors) that is the reason for the 404 instead of the actual .htaccess 404.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top