Thread: 404 Error Code

    #1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2017
    Posts
    62
    Rep Power
    1

    404 Error Code


    How to add that the 404 error code page will be active if let's say art.php?id=1 is missing?
    I am referring to the id=1 missing and not the art.php page.
    Although the id is missing i always get 200 code since the page itself is there.
  2. #2
  3. Lazy Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    16,436
    Rep Power
    9645
    Use
    PHP Code:
    http_response_code(404); 
    before any output, then show some appropriate error page/message.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2017
    Posts
    62
    Rep Power
    1
    Ohh, i get it.
    Thank you
  6. #4
  7. Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2017
    Location
    Lithuania
    Posts
    22
    Rep Power
    0
    Just in case you use PHP version lower than 5.4 and have no option to upgrade, http_response_code will not work for you. Instead, you can use header() function to return a header with 404 error.

IMN logo majestic logo threadwatch logo seochat tools logo