Request: /some/old/folder/*
Destination: /*
$url = $_SERVER['REQUEST_URI']; // например, там будет /qwerty/////asdf/zxcv/ghjk//yahoo/;
$pattern = "~\/{2,}~";
if(preg_match($pattern, $url) !== false){
$newUrl = preg_replace($pattern, '/', $url);
header("HTTP/1.1 301 Moved Permanently");
header('Location: http://'.$_SERVER['SERVER_NAME'].newUrl);
exit();
}