1) { header('Location: /'); exit(); } array_shift($patharray); array_shift($patharray); $path = '/'; $query = ''; $newpath_array = array(); $query_array = array(); $key = array_search('args', $patharray); if ($key !== FALSE) { $newpath_array = array_slice($patharray, 0, $key); $query_array = array_slice($patharray, $key+1); } else { $newpath_array = $patharray; } $args = array_chunk($query_array, 2); $first = true; foreach ($args as $arg) { if (count($arg) == 2) { switch ($arg[0]) { case 'annee': if (!$first) { $query .= '&'.$arg[0].'[value][year]='.$arg[1]; } else { $query .= $arg[0].'[value][year]='.$arg[1]; $first = false; } break; default: $tids = explode(',', $arg[1]); foreach ($tids as $tid) { if (!$first) { $query .= '&'.$arg[0].'[]='.$tid; } else { $query .= $arg[0].'[]='.$tid; $first = false; } } break; } } } $path = '/'.implode('/', $newpath_array); if (!empty($query)) { $path .= '?'.$query; } header("Status: 301 Moved Permanently", false, 301); header('Location: '.$path); exit(); ?>