fbiville
fbiville

Reputation: 8960

PHP Force Apache error

Thanks to this forum, I learnt PHP header function does not actually send header to Apache server but only to the client.

What I wanna do is to generate an error 500, and let Apache displays its corresponding page. Is there a way to force it ?

Thanks in advance ! (and allez les bleus !)

Upvotes: 5

Views: 6605

Answers (3)

Bjorn Moeller
Bjorn Moeller

Reputation: 1

Just do a broken cgi script:

// Don't include stdio
int main() {
   printf("This won't work.\n");
   return 0;
}

Upvotes: 0

Piskvor left the building
Piskvor left the building

Reputation: 92772

There's a way of sending a 500 Error to the browser, but you'll have to provide the page yourself:

<?php
header('HTTP/1.1 500 Internal Server Error');
echo <<<ERRORTEXT
The server encountered an unexpected condition which prevented it 
from fulfilling the request.
ERRORTEXT;
// also notify server operator, maybe?
exit;
?>

Upvotes: 4

zaf
zaf

Reputation: 23264

Do a redirect to a URL that causes a 500.

For example a url with an invalid .htaccess directive.

Upvotes: 3

Related Questions