@@ -10,7 +10,7 @@ trailing slash to the same URL without a trailing slash
10
10
11
11
Create a controller that will match any URL with a trailing slash, remove
12
12
the trailing slash (keeping query parameters if any) and redirect to the
13
- new URL with a 301 response status code::
13
+ new URL with a 308 response status code::
14
14
15
15
// src/AppBundle/Controller/RedirectingController.php
16
16
namespace AppBundle\Controller;
@@ -27,7 +27,7 @@ new URL with a 301 response status code::
27
27
28
28
$url = str_replace($pathInfo, rtrim($pathInfo, ' /'), $requestUri);
29
29
30
- return $this->redirect($url, 301 );
30
+ return $this->redirect($url, 308 );
31
31
}
32
32
}
33
33
@@ -50,7 +50,7 @@ system, as explained below:
50
50
{
51
51
/**
52
52
* @Route("/{url}", name="remove_trailing_slash",
53
- * requirements={"url" = ".*\/$"}, methods={"GET"} )
53
+ * requirements={"url" = ".*\/$"})
54
54
*/
55
55
public function removeTrailingSlashAction(Request $request)
56
56
{
@@ -65,7 +65,6 @@ system, as explained below:
65
65
defaults : { _controller: AppBundle:Redirecting:removeTrailingSlash }
66
66
requirements :
67
67
url : .*/$
68
- methods : [GET]
69
68
70
69
.. code-block :: xml
71
70
@@ -92,20 +91,10 @@ system, as explained below:
92
91
),
93
92
array(
94
93
'url' => '.*/$',
95
- ),
96
- array(),
97
- '',
98
- array(),
99
- array('GET')
94
+ )
100
95
)
101
96
);
102
97
103
- .. note ::
104
-
105
- Redirecting a POST request does not work well in old browsers. A 302
106
- on a POST request would send a GET request after the redirection for legacy
107
- reasons. For that reason, the route here only matches GET requests.
108
-
109
98
.. caution ::
110
99
111
100
Make sure to include this route in your routing configuration at the
0 commit comments