ErrorDocument 404 /error.php

<?php
    header("Location: http://example.com/");
? >