http://www.perlmonks.org?node_id=938319


in reply to Set HTTP Status code

First check the HTTP server's access and error logs. There will probably be a message in the error log saying that test.pl was not found, but you may find a more specific reason. If not, you will have to figure out why the server can't find (or can't open) the script.

There are several possibilities. First, check that the URL you use really corresponds to the directory where the script is. Commonly, a test.pl script would be in a cgi-bin directory and the URL needs to end in .../cgi-bin/test.pl.

Another possibility is that test.pl is not executable by the HTTP server; an ls -l will show you if the appropriate execute bits are missing, or if the file ownership isn't what you expected.

Replies are listed 'Best First'.
Re^2: Set HTTP Status code
by molybtek (Novice) on Nov 16, 2011 at 22:39 UTC

    We are using Apache 2.2 web server.

    The server does find the code and is executing it - if I removed the code to change the status, it will display the output from the program, and the status is 200 OK.

    However, I want it to display a status of 404 Not Found, so when I included the code $self->header_props(-status => 404);, I get the error message instead of the output from the program.

    I've checked the error log, there are no entry for it.