1

I'm writing an apache 2.4 Rewrite rule in order to remove a query string param and create a cookie from its value.

eg:

http://example.com/?param1=value1&my_param=my_value&param2=value2

to

http://example.com/?param1=value1&param2=value2

i'm successfully using apache RewriteRule to set a cookie but i would like to set the prepended query string param value as cookie value.

if i remove my_param=my_value from the query string

i want the value of the cookie to be my_value

this is what i've done so far, the only problem is that i can't figure out out to retrieve "my_value".

RewriteCond %{QUERY_STRING}  (.*)(?:^|&)utm_source=(?:[^&]*)((?:&|$).*)

RewriteCond %1%2 (^|&)([^&].*|$)

RewriteRule ^(.*)$ $1?%2 [CO=utm_source:my_value_here:.example.org:1440:/,R=301]

Any help would be greatly appreciated !

erwan
  • 121
  • 2
  • 6

1 Answers1

1

my mistake was the 301 that perform caching, i get it working with a simpler rewriteRule

RewriteCond %{QUERY_STRING} ^(.*)my_param=([^&]+)&?(.*)$
RewriteRule ^(.*)$ /$1?%1%3 [CO=my_param:%2:.example.com:1440:/,R=302]
erwan
  • 121
  • 2
  • 6