Skip to content

Commit

Permalink
[#6124] Remove some escapes
Browse files Browse the repository at this point in the history
  • Loading branch information
wouterj committed Feb 6, 2016
1 parent d340a6a commit d3744cb
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions cookbook/routing/redirect_trailing_slash.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,7 @@ system, as explained below:
*/
public function removeTrailingSlashAction(Request $request)
{
$pathInfo = $request->getPathInfo();
$requestUri = $request->getRequestUri();
$url = str_replace($pathInfo, rtrim($pathInfo, ' /'), $requestUri);
return $this->redirect($url, 301);
// ...
}
}
Expand All @@ -68,7 +63,7 @@ system, as explained below:
path: /{url}
defaults: { _controller: AppBundle:Redirecting:removeTrailingSlash }
requirements:
url: .*\/$
url: .*/$
methods: [GET]
.. code-block:: xml
Expand All @@ -77,7 +72,7 @@ system, as explained below:
<routes xmlns="http://symfony.com/schema/routing">
<route id="remove_trailing_slash" path="/{url}" methods="GET">
<default key="_controller">AppBundle:Redirecting:removeTrailingSlash</default>
<requirement key="url">.*\/$</requirement>
<requirement key="url">.*/$</requirement>
</route>
</routes>
Expand All @@ -95,7 +90,7 @@ system, as explained below:
'_controller' => 'AppBundle:Redirecting:removeTrailingSlash',
),
array(
'url' => '.*\/$',
'url' => '.*/$',
),
array(),
'',
Expand Down

0 comments on commit d3744cb

Please sign in to comment.