Append a parameter to a querystring with mod_rewrite
- by Matt
Hello,
I would like to use mod_rewrite to append a parameter to the end of a querystring. I understand that I can do this using the [QSA] flag.
However, I would like the parameter appended ONLY if it does not already exist in the querystring. So, if the querystring was:
http://www.mysite.com/script.php?colour=red&size=large
I would like the above URL to be re-directed to
http://www.mysite.com/script.php?colour=red&size=large&weight=heavy
Where weight=heavy is appended to the end of the querystring only if this specific parameter was not there in the first place! If the specific parameter is already in the URL then no redirect is required.
Can anybody please suggest code to put in my .htacess file that can do this? Thanks.