PHP Code:header("HTTP/1.0 404 Not Found");
Is that all there is to it, or should I be doing something else? Should I be sending a Location header as well? (I've defined a 404 page in my .htaccess)
Printable View
PHP Code:header("HTTP/1.0 404 Not Found");
Is that all there is to it, or should I be doing something else? Should I be sending a Location header as well? (I've defined a 404 page in my .htaccess)
Hmm, doesn't seem right. Just gives a blank page. I should try exit();
Addendum.
I have an index.php which I want to 301 redirect to xyz.php. I try this:
But I get "Cannot modify header information", because index.php already exists...PHP Code:
<?php
header("HTTP/1.1 301 Moved Permanently");
header("Location: /xyz.php");
exit();
?>
404 solved, it was obvious. No output allowed after exit(), so I should 'get' the 404 page before I exit();
PHP Code:header("HTTP/1.0 404 Not Found");
include realpath($_SERVER['DOCUMENT_ROOT'] . '/404.html');
exit();
Is there a reason you cannot use the ErrorDocument directve in Asplache? It's better to do this if possible rather than include you own page.
Quote:
Originally Posted by visualAd
Because Asplache ate my toenails.
Also, not all shared hosts give you this kind of access. I have .htaccess access. Maybe if I write to my host's admins, they'll give me Asplache access. :afrog:
Stop that. :mad: They may allow you to use it ;)
You cannot do both. If you have access to your .htaccess file you should be able to use the ErrorDocument directive and bypass PHP altogether. If you are rewriting all URLs to a PHP script then you should use the header() and include() method.Quote:
Originally Posted by mendhak
I'll do that, thanks.