I posted about this on another forum, and figured I'd share. I rarely see almost any sites using this, but it like an incredibly simple leap of logic in my opinion. when you have urls like page.php?ref=x, "link power" flows for the search engines, but to the wrong place. what you want, ideally, is for that power to be flowing to page.php. and it's more than possible. most people don't realize this for some reason. you can send out a 301 as long as headers have not been sent. in other words, you can do pre-processing server-side and then send the 301 later. I do something like this... (I use php, but there's no reason the same logic can't be applied to any other server-side language, I'm pretty sure) the visitor clicks on page.php?ref=x the request is sent to the server. a variable is stored, say, through $ref = $_GET['ref']; 301 headers are sent if ($ref) { header("HTTP/1.1 301 Moved Permanently"); header("Location: http://www.domain.com/page.php"); } regular, post-header processing just use the variable $ref to see who the referrer was for the page. and keep in mind, referral / affiliate links aren't just for ecommerce sites. I've set things up on a lot of my sites so users get "rewards" of one sort or another (no ads, special privs, etc) for referring users.
do you know what type of redirect happens if you do not inlcude the first header? ie only this header("Location: http://www.domain.com/page.php"); I have been doing something similar at my site, but without explicitly setting the 301 header.
never done that. I'm sure you could test it to find out fairly easily though. if you do, let me know how it works.
Figured it out. without setting any headers, the "location: url" sends a 302 (moved temporarily) so definitely better to set the header as a 301, like you did.