File tree Expand file tree Collapse file tree 3 files changed +40
-1
lines changed
Filter options
Expand file tree Collapse file tree 3 files changed +40
-1
lines changed
Original file line number Diff line number Diff line change 84
84
85
85
* :doc:` /cookbook/routing/scheme`
86
86
* :doc:` /cookbook/routing/slash_in_parameter`
87
+ * :doc:` /cookbook/routing/redirect_in_config`
87
88
88
89
* ** symfony1**
89
90
128
129
* :doc:` /cookbook/workflow/index`
129
130
130
131
* :doc:` /cookbook/workflow/new_project_git`
131
- * :doc:` /cookbook/workflow/new_project_svn`
132
+ * :doc:` /cookbook/workflow/new_project_svn`
Original file line number Diff line number Diff line change 6
6
7
7
scheme
8
8
slash_in_parameter
9
+ redirect_in_config
Original file line number Diff line number Diff line change
1
+ .. index ::
2
+ single: Routing; Configure redirect to another route without a custom controller
3
+
4
+ How to configure a redirect to another route without a custom controller
5
+ ========================================================================
6
+
7
+ This guide explains how to configure a redirect from one route to another
8
+ without using a custom controller.
9
+
10
+ Let's assume that there is no useful default controller for the ``/ `` path of
11
+ your application and you want to redirect theses requests to ``/app ``.
12
+
13
+ Your configuration will look like this:
14
+
15
+ .. code-block :: yaml
16
+
17
+ AppBundle :
18
+ resource : " @App/Controller/"
19
+ type : annotation
20
+ prefix : /app
21
+
22
+ root :
23
+ pattern : /
24
+ defaults :
25
+ _controller : FrameworkBundle:Redirect:urlRedirect
26
+ path : /app
27
+ permanent : true
28
+
29
+ Your ``AppBundle `` is registered to handle all requests under ``/app ``.
30
+
31
+ We configure a route for the ``/ `` path and let :class: `Symfony\\ Bundle\\ FrameworkBundle\\ Controller\\ RedirectController ` handle it.
32
+ This controller is builtin and offers two methods for redirecting request:
33
+
34
+ * ``redirect `` redirects to another *route *. You must provide the ``route `` parameter with the *name * of the route you want to redirect to.
35
+ * ``urlRedirect `` redirects to another *path *. You must provide the ``path `` parameter containing the path of the resource you want to redirect to.
36
+
37
+ The ``permanent `` switch tells both methods to issue a 301 HTTP status code.
You can’t perform that action at this time.
0 commit comments