tags:

views:

102

answers:

2

I have the following RewriteRule in my .htaccess:

RewriteRule ^products/([A-Za-z0-9-\s\@]+)/([A-Za-z0-9-\s\@]+)/?$ /store/products/product.php?prod=$1&src=$2 [L,QSA]

It takes a url such as: http://photojojo.com/store/products/lawnmower/blogThatLovesUs

and shows the page here: http://photojojo.com/store/products/product.php?prod=lawnmower&src=blogThatLovesUs

Is there a way I can edit this RewriteRule so that the user just sees http://photojojo.com/store/products/lawnmower/ (sans blogThatLovesUs) in their address bar?

+1  A: 

Sure, you can do that, but you will lose your affiliate's ID (blogThatLovesUs) in the process. You could use your original URL to redirect as you are doing, and then have the resulting page (product.php) cache the affiliate value in session and then do a standard redirect in PHP (with header()) to the updated URL without the affiliate value. Does that make sense?

I want to illustrate to be more clear:

URL: http://photojojo.com/store/products/lawnmower/blogThatLovesUs

through RewriteRule you end up with:

URL: http://photojojo.com/store/products/product.php?prod=lawnmower&src=blogThatLovesUs

At this point, in product.php you store blogThatLovesUs off in session somewhere and then:

<?php
    header("Location: http://photojojo.com/store/products/lawnmower/");
?>

To get the browser to the URL you want them at.

Sean Bright
A: 

Worked great, thanks! I just had to do the redirect via jscript instead of php because I needed to first run some google analytics via javascript on the referral.

Susan