Jump to content

Redirect behavior has changed with hosting migration


Antialias

Recommended Posts

I have a script that redirects to a filename stored in a mysql db. This is so that the filename can change but I always have a static link to whatever content is refered to in the DB. Previously the redirect was showing the original url(outputfile.php?id=#) now after our hosting company migrated some servers around, the final url displayed is the actual file name which is randomly assigned in the upload script and changes so users can bookmark and get the correct location.

 

I imagine something changed in the version of apache or php they are using but how can I maintain the referring URL rather than the final URL? Here is my code:

 

<?

$id = $_REQUEST['id'];

if(empty($id)){

    echo "Unable to locate file";

    exit();

}

 

require('./file_api.php');

$item = array_shift(getfiles(array('fileid'=>$id)));

 

//If we're trying to feed up a bidder's package redirect the browser to the bidder's package output file

if($item['itemtype'] == 'bidders_package'){

    header('location: /sellers/bidders.php?id='.$item['id']);

   

    exit();

}

preg_match("/(\w+)$/U",$item['filelocation'],$matches);

//print_r($item);

if($matches[1] == 'pdf'){

    preg_match("/\/([.\w\d]+)$/U",$item['filelocation'],$matches);

//    print_r($matches);

//echo "redirecting"; exit();

    header('location: /files/'.$matches[1]);

    exit();

}

 

header('Content-type: '.$item['mimetype']);

header("Content-Disposition: inline; filename=file.".$matches[1]);

flush();

$fp = fopen($item['filelocation'],'rb');

fpassthru($fp);

fclose($fp);

 

?>

 

Thanks!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.