.... if ($args ~ "_escaped_fragment_=/?(.+)/(.+)") { set $pathl $1; set $pathp $2; rewrite ^ /snapshot____${pathl}_${pathp}.html; } ....