I didn't understand it why happens. When I try to get other errors they are including to the page so I can see the error but 404.php couldn't included.
<?php
include('views/nav.php');
if (isset($_GET['id'])){
$id = preg_replace('#[\s]+#',' ',htmlspecialchars($_GET['id'], ENT_QUOTES, 'UTF-8'));
if ( is_numeric($id) ) {
try{
$query->execute();
$blogs = $query->fetchAll();
if( empty($blogs) ) {
include('error_pages/404.php'); # DOESN'T WORK
} else {
foreach ($blogs as $blog) {
include('views/article.php');
}
}
// Close connection.
$conn = null;
} catch(PDOException $e) {
include('error_pages/500.php'); # THIS ONE IS WORKS.
// echo "Connection failed: " . $e->getMessage();
}
} else {
include('error_pages/400.php'); # THIS ONE IS WORKS.
}
} else {
include('views/blog.php');
}
include('views/footer.php');
?>
I tested these steps;
Finally I found the solve. I was created a directory on web project it was /error_pages/ and it's owner was me and the group of it was www-data (I'm working on NGINX). I wanted to go and check for permissions. When I type the 'ls -l' it returned the 'owner:owner' value. You need to to that for NGINX;
Execute the following command on terminal. This command will set group of your web project as www-data.
Problem solved ^-^