Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP Force Apache error

Tags:

php

apache

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 !)

like image 479
fbiville Avatar asked Jun 09 '10 09:06

fbiville


2 Answers

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;
?>
like image 111
Piskvor left the building Avatar answered Nov 04 '22 05:11

Piskvor left the building


Do a redirect to a URL that causes a 500.

For example a url with an invalid .htaccess directive.

like image 3
zaf Avatar answered Nov 04 '22 06:11

zaf