Redirect from a PDF file

Hi I wonder if anyone can help. I have a server redirect from 2 outdated pdfs to a gallery page. On this gallery page I have this PHP code to redirect to the the new pdf based on the previous url entered.

<?php
$url = $_SERVER['HTTP_REFERER'];
if ($url == 'http://www.example.com/oldpdf1.pdf') {
header( "HTTP/1.1 301 Moved Permanently" );
header( "Location: http://www.example.com/newpdf1.pdf" );	
} elseif ($url == 'http://www.example.com/oldpdf2.pdf') {
header( "HTTP/1.1 301 Moved Permanently" );
header( "Location: http://www.example.com/newpdf1.pdf" );	
}
?>

This code works fine on our dev server - but on the live server the user just stays on the gallery page!

Any ideas why?

Thanks
Steven

In order of preference to see what is going on, add:


echo $url ;


//or pipe to your error logs with trigger_error() 
$debug = var_export( $_SERVER) ;

// or even temporarily use - if you are feeling brave
var_dump($_SERVER);