title: using header() on htaccess for 404 not found
body: <p>Some of web pages are actually contained in my database.
  I have the htaccess with the following</p>
  
  <pre><code>ErrorDocument 404 /error404.php
  </code></pre>
  
  <p>My error404 do a <code>require("checkdb.php");</code>
  which check if the filename is represented in MySQL db. If so, I want to return 200 OK and spit out the content.
  If not, I want to spit out that 404</p>
  
  <p>My problem is I'm stuck with 404. While my page is properly displayed, it won't get picked up by search engine and the google+ doesn't work has it does a check for the page and it gets 404.</p>
  
  <p>I've added </p>
  
  <pre><code>header('HTTP/1.1 200 OK'); 
  </code></pre>
  
  <p>right after a check in the database (no html code has been displayed yet), but I get the</p>
  
  <blockquote>
    <p>Warning. Cannot modify header information - headers already sent by ....</p>
  </blockquote>
  
  <p>Even if I move that <code>header()</code> right at the beginning of <code>/error404.php</code>  I still get that error. It sounds like Apache will return that 404 first and then call <code>/error404.php</code></p>
  
  <p>What can I do to properly fix this?
  Thanks very much in advance!</p>