Do NOT duplicate the page that will get you penalized/banned for duplicate content.
Have a single php file on domain.com and domain2.com named index.php and inside do a proper 301...
PHP Code:
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://www.domain1.com");
exit();