0

I have 3 files: index.php,.htaccess,404.shtml

index.php contains:

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

.htaccess contains:

ErrorDocument 404 /404.shtml

404.shtml contains:

Hello World

when i visit index.php my browser tells me oops something went wrong. What might possibly have gone wrong?

Zhianc
  • 1,411
  • 3
  • 20
  • 37

1 Answers1

0

I think because .htaccess comes first and the server would redirect to it only if the physical file really doesn't exists.

If you handle 404 via php header you should handle it either for real user eg. with

 <?
 header("Location: /this/page/really/not_exists.404"); //  trigger "real" 404
 //or
 header("Location: /404.shtml");

for reference try looking here Why won't my PHP app send a 404 error?

Community
  • 1
  • 1
lcapra
  • 1,420
  • 16
  • 18