2

Is there a way to redirect the users to the homepage whenever the user enters a wrong url?

Let's say app.php/Contact triggers a 404 error and I would like all 404 errors to be redirected to the homepage?

I am pretty sure I read that somewhere at a time, but can't find it anymore. I think it was a else statement in the config file?

4

2 に答える 2

1

ExceptionControllerを拡張showAction()し、必要なロジックで再定義する必要があります。

単に次のように:

if (404 === $exception->getStatusCode()) {
    //do your logic
}
于 2012-07-31T13:25:54.893 に答える
0

.htaccess ファイルを使用して、次の行を追加します。

ErrorDocument 404 /home.php
于 2012-07-31T13:08:08.670 に答える