Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

print "location:" - is this a 301

Status
Not open for further replies.

1DMF

Programmer
Jan 18, 2005
8,795
GB
Hello,

Basically as per the heading, If I use
Code:
print "Location:URL\n\n";

Is this the same as a 301 redirect and so the resulting page is actually what a spider / search engine see's rather than the perl CGI script?

thanks,

1DMF



"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!
 
ok from what i've been reading this is a 302 not 301

I've found this code
Code:
#!/usr/bin/perl      -w
use strict;
print "Status: 301 Moved Permanantly\n";
print "Location: [URL unfurl="true"]http://somewhere/page.htm\n\n";[/URL]
exit;

along with this
Code:
use CGI; 
my $q = CGI->new(); 
print $q->redirect( 
-location => '[URL unfurl="true"]http://someothersite.com/page1.cgi',[/URL] 
-status => 301, 
);

Which is better?

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!
 
I can honestly say I have no idea :) I usually just let apache handle the error pages.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those Who Say It Cannot Be Done Are Usually Interrupted by Someone Else Doing It; Give the wrong symptoms, get the wrong solutions;
 
AFAIK it's just a matter of style. The first is the manual way to code the redirect, and the second is the CGI object-oriented way to generate the same HTTP headers.

There may be more going on under the surface (or not), but the results are the same.
 
I usually just let apache handle the error pages
yeah but this is ActiveState on IIS / Windows box.

if only there was a .htaccess function :-(

I think i prefer the cgi OO method, looks like it's easier to issue different status codes.

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top