Is the missing semicolons genuine, or are they typos in your post?
For the sake of experimentation ('cos I want to help, but can't see anything obviously wrong), try this construct as a switch():
switch($HTTP_REFERER)
{
case 'page1.html':
$page='1';
$rank='1';
$redirect='page1a.html';
break;
case 'page2.html':
$page='2';
$rank='2';
$redirect='page2a.html';
break;
case 'page3.html':
$page='3';
$rank='3';
$redirect='page3a.html';
break;
default:
$page='0';
$rank='0';
}
Yes, I know I'm using single quotes instead of double - it shouldn't make any difference though 'cos there's no variable interpolation going on. I'm just too lazy to bounce on the shift key alla time 🙂