Sending back 404 error

W

Winston Kotzan

Hi,

I have a Perl script that creates dynamic pages using a passed page
variable. If someone tries to access a page that does not exist, I want my
script to send back a custom 404 error. The problem is that I want to make
sure the HTTP 404 status code is sent back to the browser, and not just an
HTTP 200 response with a page displaying an error. The reason is that I
want to see the 404 status code in my Apache server logs. What command can
I use to send the correct HTTP status code?

Thanks.
 
G

Gunnar Hjalmarsson

Winston said:
I have a Perl script that creates dynamic pages using a passed page
variable. If someone tries to access a page that does not exist,
I want my script to send back a custom 404 error. The problem is
that I want to make sure the HTTP 404 status code is sent back to
the browser, and not just an HTTP 200 response with a page
displaying an error. The reason is that I want to see the 404
status code in my Apache server logs. What command can I use to
send the correct HTTP status code?

print "Content-Type: text/html; charset=iso-8859-1\n";
print "Status: 404 Not Found\n" if [not exist];
print "\n";
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top