read cookie with htaccess and add cookie value to URI
In htaccess with mod_rewrite, how can I read the value of a cookie and then add that value to the URI?
For example, if a cookie named "foo" is set with a value of "bar", I need htaccess to redirect to:
example.com/?foo=bar
or any variation of that URL:
example.com/fo开发者_运维技巧lder/stuff/things/?foo=bar
I haven't tested, but this probably works (the B
flag was purposely omitted):
RewriteCond %{HTTP_COOKIE} (?:^|;\s*)foo=([^;]*)
RewriteRule .* $0?foo=%1 [L,QSA,NS]
精彩评论