Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm testing client software which responds differently depending on a webserver's response code.

For the purposes of testing, I need to configure my Apache server to return specific error codes, such as 500, 403, and many others.

I don't want to have to produce the condition for each error code, I just want to return the error code to the browser/client for testing.

Hopefully the syntax is simple such as the case of a redirect:

Redirect 303 /two http://example.com/other

But in theory I would like something like this:

Redirect 500 /test /test2

Does anybody know how to do this?

Thanks!

share|improve this question

1 Answer 1

up vote 0 down vote accepted

Why not use a PHP-header to do this?

<?php
header("HTTP/1.0 404 Not Found");
?>

Will simply return a 404 error.

http://www.jonasjohn.de/snippets/php/headers.htm has a list of all available error headers.

The reason you'd not be getting a page saying "404 - not found" would be that the server itself isn't sending one while the web browser knows it exists (After all, the server is replying with 404). The web browser WILL be receiving the correct error code and detect it though.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.