"); printf("
"); print_r($_SERVER); printf("
"); print_r($_GET); printf("
"); print_r($_POST); */ $requested_path = $_REQUEST['requested_path']; $info = pathinfo($requested_path); if (!isset($info['extension'])) $info['extension'] = ''; print_r($info); if (RedirectForExtension($info['extension'])) { // bounce to the other server if the extension // matches those in listing below $location = $redirect_server_url . $requested_path; //echo "Redirecting to $location"; //header ('HTTP/1.1 301 Moved Permanently'); header ('Location: '.$location); exit(); } else if (file_exists($requested_path)) { // if the file exists (we shouldnt have gotten // here because of rewrite rule but just in case // echo the contents of the file out to the client echo file_get_contents($requested_path); exit(); } else { // file isnt on the server (404) and isnt // a type we redirect for, send the client // to the error page //echo "Redirecting to $error_page_template"; header ('Location: '.$error_page_template); exit(); } //////////////////////////////////////////////////////////////////////////////// function RedirectForExtension($ext) { $ext = strtolower($ext); $valid_extensions = array('mov', 'm4a', 'm4v', 'avi', 'mp4', 'wmv', 'mpg', 'mp3', 'wav'); return in_array($ext, $valid_extensions); }