1
1
.. index ::
2
2
single: Routing; Redirect using Framework:RedirectController
3
3
4
- How to Configure a Redirect Without a Custom Controller
4
+ How to Configure a Redirect without a Custom Controller
5
5
=======================================================
6
6
7
7
Sometimes, a URL needs to redirect to another URL. You can do that by creating
8
- a new controller action which only task is to redirect, but using the
8
+ a new controller action whose only task is to redirect, but using the
9
9
:class: `Symfony\\ Bundle\\ FrameworkBundle\\ Controller\\ RedirectController ` of
10
- the FrameworkBundle, it's a lot easier.
10
+ the FrameworkBundle is even easier.
11
11
12
12
You can redirect to a specific path (e.g. ``/about ``) or to a specific route
13
- using it's name (e.g. ``homepage ``).
13
+ using its name (e.g. ``homepage ``).
14
14
15
15
Redirecting Using a Path
16
16
------------------------
@@ -26,7 +26,7 @@ action to redirect to this new url:
26
26
27
27
# app/config/routing.yml
28
28
29
- # loading the App controllers
29
+ # load some routes - one should ultimately have the path "/app"
30
30
AppBundle :
31
31
resource : " @AcmeAppBundle/Controller/"
32
32
type : annotation
@@ -49,7 +49,7 @@ action to redirect to this new url:
49
49
xsi : schemaLocation =" http://symfony.com/schema/routing
50
50
http://symfony.com/schema/routing/routing-1.0.xsd" >
51
51
52
- <!-- loading the App controllers -->
52
+ <!-- load some routes - one should ultimately have the path "/app" -->
53
53
<import resource =" @AcmeAppBundle/Controller/"
54
54
type =" annotation"
55
55
prefix =" /app"
@@ -71,7 +71,7 @@ action to redirect to this new url:
71
71
72
72
$collection = new RouteCollection();
73
73
74
- // loading the App controllers
74
+ // load some routes - one should ultimately have the path "/app"
75
75
$acmeApp = $loader->import(
76
76
"@AcmeAppBundle/Controller/",
77
77
"annotation"
@@ -90,9 +90,9 @@ action to redirect to this new url:
90
90
return $collection;
91
91
92
92
In this example, you configured a route for the ``/ `` path and let the
93
- ``RedirectController `` handle it to redirect it to ``/app ``. The ``permanent ``
94
- switch tells the action to issue a ``301 `` HTTP status code instead of the
95
- default ``302 `` HTTP status code.
93
+ ``RedirectController `` redirect it to ``/app ``. The ``permanent `` switch
94
+ tells the action to issue a ``301 `` HTTP status code instead of the default
95
+ ``302 `` HTTP status code.
96
96
97
97
Redirecting Using a Route
98
98
-------------------------
0 commit comments