PDA

View Full Version : 301 redirects instead of 302 redirects for better SEO


induslady
10-09-2007, 03:45 AM
Hello,

I am tracking clicks to the various links (external or internal) in my website as follows:

http://www.mysitename.com/clicksout.php?url=http://www.othersitename.com - outgoing links

http://www.mysitename.com/clicksin.php?url=http://www.othersitename.com - incoming links

In the clicksin.php & clicksout.php, I have used the below php function to track the URL and to store the clicks and the url details in a table for reporting
header("Location: http://www.example.com/");

I was told that the above tracking links are 302 redirects which is bad for SEO.

Please can someone let me know how I can use 301 redirects in place of it?
Basically I want to capture the clicks on ougoing links and clicks on incoming links.

Appreciate help in this regard. Thanks.

Dismounted
10-09-2007, 07:49 AM
header('HTTP/1.1 301 Moved Permanently');
header('Location: http://www.example.com/');

Analogpoint
10-09-2007, 09:08 AM
You can set the header and response code in one header() call. And be sure to end the script right after this as well

header('Location: http://somewhere.com/', 1, 301);
exit;

induslady
10-12-2007, 02:54 AM
Hello Analogpoint and Dismounted,

Thank you for your inputs on the 301 redirects.

I change my redirects from 302 to 301 and it helped.