You forgot the newlines:
mac_body = '%s\n%s\n%s\n%s\n%s' % (path, redirect,
^^--^^--^^--^^-- newlines
$hmac_body = 'https://blahblah/xxx/'.'http://blahblah/test.php'.'41943040'.'1'.$expires;
^--here ^--here etc....