Skip to main content

Redirecting

A number of redirect options are provided via Symfony.

Further information on redirecting is provided in the Symfony documentation - Redirecting.

<?php

// redirect to the "homepage" route
return $this->redirectToRoute('homepage');

// do a permanent - 301 redirect
return $this->redirectToRoute('homepage', [], 301);

// redirect to a route with parameters
return $this->redirectToRoute(
'blog_show',
[
'slug' => 'my-page',
]
);

// redirect externally
return $this->redirect('http://symfony.com/doc');