PHP - Display a 404 Error without redirecting to another page

后端 未结 6 1555
天涯浪人
天涯浪人 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:36

    Include the error page in your current page and send a 404 error status code:

    
    

    Note that this should be used if the page should never be seen. A better status code for un-authorized access (if the page should be seen by some logged in users) is 403 (Not Authorized).

提交回复
热议问题