views:

26

answers:

2

I currently use register.php?referal=gamestand on my website so that when the user visits my website through the referal website, I can track how many players have registered from that place.

referal=gamestand will automatically fill in an input textfield within the registration process using echo $_GET['code'];

The problem is... on Google I have loads of links from these referals and I'd like to 301 them to my register.php page to merge the SEO score into one and eventually remove these silly register.php?code=gamestand style links from google.

I've got this rewrite rule... which removes the ?code=gamestand bit, but it doesn't actually pass the parameter, probably because it's redirecting and sending nothing?

RewriteCond %{QUERY_STRING} ^(.*)code(.*)$
RewriteRule ^(.*)$ http://localhost/mywebsite/httpdocs/register.php? [R=301,L] 

it will change register.php?code=gamestand into register.php but as I said, $_GET['code'] is now empty and I'm back to square one!

Appreciate any help if anyone knows anything... Thanks! Dom

A: 

You could store the referrer in a session variable, then redirect to register.php without the code. Your URL won't contain the code any more, but it's available via the session.

session_start();
if (isset($_GET['code'])) {
  $_SESSION['code'] = $_GET['code'];
  header('Location: register.php');
  exit;
}

...

echo $_SESSION['code'];
casablanca
A: 

Redirecting these Urls to the same Url probably won't merge your SEO score into one. Your current method is fine, don't mess with it.

James Lawruk