Answer the question
In order to leave comments, you need to log in
How to make a 404 redirect when routing?
Not so long ago, Toaster suggested me a very cool topic with routing and php, thank you very much:3
And now, when I almost rewrote my "engine", I had a question about 404 redirects.
I tried to do this:
First, if the url does not fit any rules, the router thinks that this is an article (because the article can be anywhere).
else {
$this -> set('ContentManager', new ArticleManager($address, $this['database']));
$route_to = 'article';
}
if (count($this -> mysql_content) == 0) {
header( "Location: /error404.php", true, 404 );
exit();
}
ErrorDocument 404 http://klimatdomu.ru/error404.php
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.klimatdomu.ru$ [NC]
RewriteRule ^(.*)$ http://klimatdomu.ru/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?route=$1 [L,QSA]
Answer the question
In order to leave comments, you need to log in
header( "Location: /error404.php", true, 404);
The browser is getting a 404 response and is most likely not executing "Location: /error404.php" because of this.
Try thisheader("Location: /error404.php", true);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question