[Chicago-talk] Generate a 404 error from a perl script

Jim Jacobus JJacobus at PonyX.com
Wed Dec 23 11:18:24 PST 2015

Well, that was easy. Now I feel dumb.
Thank you.

At 12:51 PM 12/23/2015, Don Drake wrote:

>Take a look at this example:
>$remote_host = $ENV{'REMOTE_HOST'};
>print "Content-type: text/plain", "\n";
>if ($remote_host eq "<http://bu.edu>bu.edu") {
>         print "Status: 200 OK", "\n\n";
>         print "Great! You are from Boston University!", "\n";
>} else {
>         print "Status: 400 Bad Request", "\n\n";
>         print "Sorry! You need to access this from Boston University!", "\n";
>exit (0);
>Don Drake<http://www.drakeconsulting.com>www.drakeconsulting.com
>>On Dec 23, 2015, at 11:43 AM, Jim Jacobus 
>><<mailto:JJacobus at ponyx.com>JJacobus at PonyX.com> wrote:
>>How to I create a 404 error from a cgi-bin script. I know the 
>>message needs to be before any other text, but I'm having trouble with this.
>>Background: I have a script that is indexed by all the search 
>>engines. It has a parameter which is a item number (e.g. 
>>) where nnnnnn is a item number. The script figures out if this is 
>>a current item number and forwards it to an HTML page if it is. If 
>>it isn't a current item number, I create a page that is a similar 
>>product. The item numbers (nnnnnn) are added and deleted all the 
>>time. I want the search engines to stop indexing expired items, so 
>>I want to create a 404 error but still produce a page for the end user.
>>I thought there was a simple print statement I needed to write out, 
>>but I'm having trouble figuring out what it is.
>>Thanks in advance.
>>Chicago-talk mailing list
>><mailto:Chicago-talk at pm.org>Chicago-talk at pm.org
>Chicago-talk mailing list
>Chicago-talk at pm.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/chicago-talk/attachments/20151223/f158ed8b/attachment.html>

More information about the Chicago-talk mailing list