I'm trying to add a query parameter to the end of all URLs on a site but that value needs to be dynamic.
RewriteCond %{QUERY_STRING} !(^|&)testing=true(&|$) [NC]
RewriteRule ^ %{REQUEST_URI}?testing=true [L,QSA,R]
This answer (code above) is very close to what I need, but I need 'true' to change based on the user provided value. An example would be various campaign ID's
http://domain.com/?campaign=32324
And when a user clicks on a link from this page, those links should append the ?campaign=32324
If you want to append a query string to a URL, I believe this is what you're looking for.
Of course your parameter and/or its value can be populated in any number of ways. It can be passed from a previous page and populated by $_GET['something']
or provided by a DB query and populated from the results.
RewriteEngine On # Turn on the rewriting engine
RewriteRule ^([A-Za-z0-9_-]+)$ your-page.php?your-parameter=$1 [NC,L] # Handle query string with no slash
RewriteRule ^([A-Za-z0-9_-]+)/$ your-page.php?your-parameter=$1 [NC,L] # Handle query string with a slash
The [A-Za-z0-9_-] portion allows a parameter value to include upper & lower case letters, numbers, underscore and hyphen. If all you want are numbers (as in your examples) simply remove everything between the square brackets except 0-9 like so... [0-9]