Nginx 301 redirect inc. set cookie
location / { set $cid ''; if ( $query_string ~ "(.*)cid\=([0-9]+)(&?)(.*)" ) { set $args $1$4; set $cid $2; } if ( $args ~ (.+)&$ ) { set $args $1; } if ( $cid != '' ) { add_header Set-Cookie tmp_cid=$cid; rewrite ^(.*)$ $1 permanent; }}