Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7884277
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T04:45:21+00:00 2026-06-03T04:45:21+00:00

I am trying to send both when a database result is empty (it’s a

  • 0

I am trying to send both when a database result is empty (it’s a product page).

My code I am using now, which works:

    header("Status: 404 Not Found");
    include_once("404.html");
    exit;

The code that I tried initially that did not work:

    header("Status: 404 Not Found");
    header("Location: 404.html");
    exit;

With the latter code, I could use either, but not both. In other words, I could send the 404 header and see it show up in Wireshark, OR I could send the Location header and redirect, but if i tried to send both, only the 404 would get sent and the Location header would nor redirect.

I have solved problem with a workable solution, but I would like to know why this is happening.

PHP 5.2 on Linux with FastCGI.

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T04:45:22+00:00Added an answer on June 3, 2026 at 4:45 am

    You can’t send both because they’re mutually exclusive.

    According to the docs for header():

    The second special case is the “Location:” header. Not only does it
    send this header back to the browser, but it also returns a REDIRECT
    (302) status code to the browser unless the 201 or a 3xx status code
    has already been set.

    So sending both would be nonsense. You’d be saying, to the browser, “That document does not exist. Also, the document was moved to the following location”. Those are contradictory.

    The solution you found is not “a workaround” — it’s the Right Way To Do It™

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The following is the program, which I am trying to send e-mail. The code
I have an issue which has arisen using Google Page Speed Online although I
I am trying to send a name:value pair to a php script using the
I am trying to send a query to SQLite from the command line using
I'm trying to send FQL multiqueries as described here without using old legacy REST
I'm currently trying to code an app to send mass SMS to 300+ numbers
I'm trying to receive and potentially send complex values through TWebBrowser (using TEmbeddedWB) with
I've been trying for days now to send mail from Grails application and unsuccessfully.
I'm using the jQuery-UI dialog and I'm trying to send the data in my
I am trying to send a video file using GNUradio, specifically using GRC. In

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.