Forum Moderators: coopster & phranque

Message Too Old, No Replies

Best way to accomplish 301 status

         

JimThomason

7:09 am on Dec 14, 2002 (gmt 0)

10+ Year Member



I have a url that currently returns a 302 in the server header checker.

[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?

andreasfriedrich

3:33 pm on Dec 14, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you have access to code.cgi then changing that will be the best way to go.

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.

[faqs.org ]

Andreas

JimThomason

1:19 am on Dec 15, 2002 (gmt 0)

10+ Year Member



Thanks Andreas. I appreciate the quick reply.

We do have full control of our code.cgi.

I'm not the programmer. I'm SEO manager. Can you expand further on the CR LF so I can pass on info to our programmer?

BTW the header you are sending is not quite correct:

Jim

andreasfriedrich

1:35 am on Dec 15, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Glad I could help Jim.

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