How to Configure a Redirect

In this example, the goal is to redirect the url "/favicon.ico" to the favicon in the assets bundle.

Create a new route document. As route name we suggest "emsch_favicon_redirect" and for the route config:

{
    "path": "/favicon.ico",
    "controller": "Symfony\\Bundle\\FrameworkBundle\\Controller\\RedirectController::urlRedirectAction",
    "defaults": {
        "path": "/bundles/emsch_assets/static/favicon.ico?v2",
        "permanent": true
    }
}

As defined in the Symfony documentation you can also redirect to a route:

{
    "path": "/news",
    "controller": "Symfony\\Bundle\\FrameworkBundle\\Controller\\RedirectController::redirectAction",
    "defaults": {
        "route": "emsch_news_home",
        "permanent": true,
        "keepQueryParams": true
    }
}