[mysite.com...]
This link redirects to index page.
#!/usr/bin/perl
print "Location: [mysite.com\n\n";...]
exit;
What is the best way to get it to return a 301 to search engines?
Use mod_rewrite module or change the redirect in the code.cgi to this
#!/usr/bin/perl
print "Status: 301 Moved Permanently\nLocation: [mysite.com\n\n";...]
exit;
Will changing the status from 302 to 301 help get the search engines to recognize the cgi link as a link to my index page?
BTW the header you are sending is not quite correct:
HTTP/1.1 defines the sequence CR LF as the end-of-line marker for all protocol elements except the entity-body.
Andreas
CR = <US-ASCII CR, carriage return (13)>
LF = <US-ASCII LF, linefeed (10)>
Those two characters are defined as the end-of-line markers.
The \n you are using is just a newline which usually is ASCII 10 = LF.
You should use \r\n or even better yet \015\012 which is ASCII 13 followed by ASCII 10. The latter is better because it specifies the actual characters while \r\n are an abstraction from the underlying real characters being used. Almost always they are the same as \015\012 but you could eliminate any troubles by being as precise as possible.
See:
- [webmasterworld.com...]
- [webmasterworld.com...]
Andreas