Forum Moderators: coopster & phranque

Message Too Old, No Replies

how to force a script to return a 404 error?

         

halayman

10:56 pm on Dec 20, 2004 (gmt 0)

10+ Year Member



I have two cases:
mydomain.com/script.cgi?string=validargument
mydomain.com/script.cgi?string=invalid

I need to add a code to my script to force a 404 error
like this

($nn,$argum)=split(/=/,$ENV{QUERY_STRING});
if ($argum="invalid")
{help code needed here to force a 404 error and exit the script.... no custom error messages please I need search engines to recognize the page doesn't exist at all};

thanks a lot

adni18

3:42 am on Dec 21, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm not sure what you mean by 'force a 404 error'. Please rephrase.

dmorison

5:33 am on Dec 21, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You could try something like:


print "Status: 404 Not Found\n\n";
exit 0;

(providing that your script has not previously started any output of course)

halayman

1:44 pm on Dec 21, 2004 (gmt 0)

10+ Year Member



thanks a lot dmorison
it works!