Set up Drupal to use alternative nodes for different incoming urls? I have a Drupal website set up selling a single product. Currently the transactions are being processed with paypal with simple buttons set up on a specified node (e.g. www.website.com/buy).

I want to start a referral or affiliate system so that drupal will notice the different incoming links (www.website.com/referral) and will then always route (www.website.com/buy) to (www.website.com/buy_referral) once it detects the different incoming links. This is because I will set up different PayPal buttons for different referrals on different buy_referral nodes.

Is there a module available to do so? or is there an easier way to do things?

Thanks for the help.
You could use the mod_rewrite features in your site's .htaccess to redirect before Drupal even gets started. This would increase performance vs. using JavaScript.

Implementation details:

https://stackoverflow.com/questions/5151385/redirect-on-the-basis-of-referer-http-referer-htaccess

More about Drupal's .htaccess:

http://drupal.org/getting-started/clean-urls

Contents of Drupal's .htaccess:

http://drupalcode.org/project/drupal.git/blob/HEAD:/.htaccess