Apache.htaccess: ErrorDocument and RewriteEngine do not work together

Please take a look at the following .htaccess

ErrorDocument 404 /404/

RewriteEngine On
RewriteRule (.*) index.php [L]

With this setup, I use header('HTTP/1.1 404 Not Found');in PHP to redirect to the error handling page and send the appropriate HTTP status code. The correct 404 status code is sent, but the browser shows a blank page and appears in the access log"GET /invalid-url/ HTTP/1.1" 404 -

Can someone tell me how to get ErrorDocument to work with rewriting Apache url?

+3
source share
4 answers

, : . , , " 404". URL- 404 " 404 ". , - , URL- 404, .

+1

404

, 404, regexp ((. *)) catchall .

htaccess. php, 404, 404 , PHP, .

+5

It should work if you define a rewrite before an ErrorDocument.

0
source

try it


ErrorDocument 404 /404.html

RewriteEngine On
RewriteRule (.*) index.php [L]

-2
source

Source: https://habr.com/ru/post/1737314/


All Articles