Note that there are some explanatory texts on larger screens.

plurals
  1. POReturning Http Status Code to Apache from PHP?
    primarykey
    data
    text
    <p>On my local development machine, I downloaded PDT + Zend Server, which included Apache 2.2.16 and PHP 5.3.5, running on Windows 7. On my local site, I included a .htaccess that includes ErrorDocuments for 404, 403, and 500. In my PHP, I use header("Http/1.0 404 Not Found") when the user requests a document that doesn't exist. On my local server, everything works great. My custom ErrorDocument appears and I'm happy.</p> <p>I upload the everything to my shared host running Apache 2.2.38 and PHP 5.3.8 on a Linux server, and suddenly the ErrorDocuments only work if they don't come from PHP.</p> <p>Is there some setting in PHP.ini or httpd.conf or .htaccess that allows Apace to see the error codes from PHP, which makes my dev server work correctly, but not my shared host?</p> <p>In researching this, all I ever saw was "Apache doesn't see the status code once it passes off to PHP." In such a case, why does my dev server work right?</p> <p><strong>Edit</strong></p> <p>For clarity, here's the .htaccess:</p> <pre><code># Use PHP 5.3 Action application/x-hg-php53 /cgi-sys/php53 AddHandler application/x-hg-php53 .php #Deny Include Files &lt;Files *.inc&gt; order deny,allow deny from all &lt;/files&gt; #Provide custom error documents ErrorDocument 404 /Errors/Http404.php ErrorDocument 403 /Errors/Http403.php ErrorDocument 500 /Errors/Http500.php </code></pre> <p>The .htaccess <strong>works</strong> because if the user navigates to myhost.com/jdkslfjdls the user receives the content of Errors/Http404.php. </p> <p>However, if the user navigates to myhost.com/images/GetImage.php?Id=5 (when there is no image #5) the user receives no content. </p> <p>If they navigate to (Internal IP Address)/images/GetImage.php?Id=5, the user receives the content of Errors/Http404.php.</p> <p>A similar problem occurs if the user tries to access GetImage.php?Id=6 (when there is an image #6 but they don't have permission). On the shared server, they get a blank page or the browser's 403 error. On my dev server, they get my actual custom 403 error page.</p> <p>Again, 403 error document works on the shared server if I try to access a .inc file.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload