开发者

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]
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜