PHP 404 not found page with no redirect + include page

Viewed 1860

i have a problem when creating custom 404 not found.

so, i had try with .htaccess :

ErrorDocument 404 http://blablabla.com/404.php

it's working!

but the problem was it's using REDIRECT. whenever i type blablabla.com/sdkfsdkjfksdhfksd

it's redirect to blablabla.com/404.php

it's changing the current URL, that's not cool. it's ugly.

what i suppose to do :

whenever i type blablabla.com/sdkfsdkjfksdhfksd

NO REDIRECT, STAY ON SAME URL. just require_once custom 404.php page.

so, i try this code :

<?php
    header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found");
    require_once "404.php";
?>

i put it on top before anycode. and this method not working. it's showing on every single page. i try type on URL blablabla.com/sdfjnsfjnksdf

the page show up with

Object not found!

The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again.

If you think this is a server error, please contact the webmaster.

how to get this things done?

what's wrong with my code?

thanks in advance...

3 Answers
Related