Reputation:
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://example.com/store/products/lawnmower/blogThatLovesUs
and shows the page here:
http://example.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://example.com/store/products/lawnmower/(sans blogThatLovesUs)
in their address bar?
Upvotes: 1
Views: 603
Reputation: 120644
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.
Upvotes: 1