# Unable to access page unless I enter trailing slash

**URL:** <https://discourse.slimframework.com/t/unable-to-access-page-unless-i-enter-trailing-slash/1121>\
**Category:** Questions\
**Created:** [February 2, 2017, 1:30pm UTC](https://discourse.slimframework.com/t/unable-to-access-page-unless-i-enter-trailing-slash/1121 "2017-02-02T13:30:32Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![robrothedev](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/robrothedev/32/137_2.png) [@robrothedev](https://discourse.slimframework.com/u/robrothedev)\
**Post date:** [February 2, 2017, 2:07pm UTC](https://discourse.slimframework.com/t/unable-to-access-page-unless-i-enter-trailing-slash/1121/2 "2017-02-02T14:07:00Z")

</div>

@bharat I’ve use this middleware for my apps and it works well:

[https://www.slimframework.com/docs/cookbook/route-patterns.html](https://www.slimframework.com/docs/cookbook/route-patterns.html)

```
// removes last backslash so /route or /route/ will work
$app->add(function ($request, $response, $next) {
    $uri = $request->getUri();
    $path = $uri->getPath();

    if ($path != '/' && substr($path, -1) == '/') {
	    $uri = $uri->withPath(substr($path, 0, -1));
	    return $response->withRedirect((string)$uri, 301);
    }
    return $next($request, $response);
});

```

Alternatively you could use this for your route:

```
$app->get('/user[/]','');

```

But you would have to do this on all of your routes.

---

_[View the full topic](https://discourse.slimframework.com/t/unable-to-access-page-unless-i-enter-trailing-slash/1121)._
