8000 Merge branch 'cookbook_routing_nocontroller' of git://github.com/tack… · skigun/symfony-docs@e3615d7 · GitHub
[go: up one dir, main page]

Skip to content

Commit e3615d7

Browse files
committed
Merge branch 'cookbook_routing_nocontroller' of git://github.com/tacker/symfony-docs into tacker-cookbook_routing_nocontroller
Conflicts: cookbook/index.rst cookbook/map.rst.inc
2 parents 75aa9d6 + ec391a9 commit e3615d7

File tree

3 files changed

+40
-1
lines changed

3 files changed

+40
-1
lines changed

cookbook/map.rst.inc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@
8484

8585
* :doc:`/cookbook/routing/scheme`
8686
* :doc:`/cookbook/routing/slash_in_parameter`
87+
* :doc:`/cookbook/routing/redirect_in_config`
8788

8889
* **symfony1**
8990

@@ -128,4 +129,4 @@
128129
* :doc:`/cookbook/workflow/index`
129130

130131
* :doc:`/cookbook/workflow/new_project_git`
131-
* :doc:`/cookbook/workflow/new_project_svn`
132+
* :doc:`/cookbook/workflow/new_project_svn`

cookbook/routing/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ Routing
66

77
scheme
88
slash_in_parameter
9+
redirect_in_config
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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.

0 commit comments

Comments
 (0)
0