PHP - Display a 404 Error without redirecting to another page

后端 未结 6 1557
天涯浪人
天涯浪人 2020-12-05 05:38

I want to display a 404 Error if a user reaches a page that exists but I don\'t want him/her to see.

I don\'t want to do redirect (that would cause the address bar t

6条回答
  •  不知归路
    2020-12-05 06:17

    You can achieve a 404 (or any other HTTP response code really) programmatically with

    header('HTTP/1.0 404 Not Found');
    die;
    

提交回复
热议问题