Skip to content

Commit 2bfa09e

Browse files
committed
[symfony#3180] Minor tweaks after proofreading new trailing slash entry
1 parent 358f2e2 commit 2bfa09e

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

cookbook/routing/redirect_trailing_slash.rst

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
Redirect URLs with a Trailing Slash
55
===================================
66

7-
The goal of this cookbook is to demonstrate how to redirect URLs with
7+
The goal of this cookbook is to demonstrate how to redirect URLs with a
88
trailing slash to the same URL without a trailing slash
99
(for example ``/en/blog/`` to ``/en/blog``).
1010

11-
You have to create a controller that will match any URL with a trailing
12-
slash, remove the trailing slash (keeping query parameters if any) and
13-
redirect to the new URL with a 301 response status code::
11+
Create a controller that will match any URL with a trailing slash, remove
12+
the trailing slash (keeping query parameters if any) and redirect to the
13+
new URL with a 301 response status code::
1414

1515
// src/Acme/DemoBundle/Controller/RedirectingController.php
1616
namespace Acme\DemoBundle\Controller;
@@ -31,8 +31,9 @@ redirect to the new URL with a 301 response status code::
3131
}
3232
}
3333

34-
And after that, register this controller to be executed whenever a URL
35-
with a trailing slash is requested:
34+
After that, create a route to this controller that's matched whenever a URL
35+
with a trailing slash is requested. Be sure to put this route last in your
36+
system, as explained below:
3637

3738
.. configuration-block::
3839

@@ -79,12 +80,13 @@ with a trailing slash is requested:
7980
8081
.. note::
8182

82-
Redirecting a POST request does not work well in old browsers.
83-
A 302 on a POST request will send a GET request after the
84-
redirection for legacy reasons.
83+
Redirecting a POST request does not work well in old browsers. A 302
84+
on a POST request would send a GET request after the redirection for legacy
85+
reasons. For that reason, the route here only matches GET requests.
8586

8687
.. caution::
8788

88-
Make sure to include this route in your routing configuration at
89-
the very end of your route listing. Otherwise, you risk to redirect
90-
Symfony2 core routes that natively do have a trailing slash.
89+
Make sure to include this route in your routing configuration at the
90+
very end of your route listing. Otherwise, you risk redirecting real
91+
routes (including Symfony2 core routes) that actually *do* have a trailing
92+
slash in their path.

0 commit comments

Comments
 (0)