Error 404 Redirect

How can i redirect to the main page of the site when occure ERROR 404?

Whenever errors occur, the action error in siteController is called. you can customize the error route in that action, you can do something like this:

public function actionError() --in site controller


     //go to custome error page


   //code default error.php