# Middleware -\>withRedirect

**URL:** <https://discourse.slimframework.com/t/middleware-withredirect/2531>\
**Category:** Questions\
**Created:** [July 13, 2018, 10:07pm UTC](https://discourse.slimframework.com/t/middleware-withredirect/2531 "2018-07-13T22:07:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![SVL](https://avatars.discourse-cdn.com/v4/letter/s/848f3c/32.png) [@SVL](https://discourse.slimframework.com/u/SVL)\
**Post date:** [July 13, 2018, 10:07pm UTC](https://discourse.slimframework.com/t/middleware-withredirect/2531/1 "2018-07-13T22:07:30Z")

</div>

Within my middleware and running Slim 3.8.1 this would indeed redirect:  
`return $response->withRedirect($this->router->pathFor('user.login'), 403);`

After upgrading to 3.10.0 that same redirect returns not output, just a blank screen.  
When removing the HTTP status code it works again.

What has changed?

---

<div class="post-metadata">

**Author:** ![tflight](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/tflight/32/1205_2.png) [@tflight](https://discourse.slimframework.com/u/tflight)\
**Post date:** [July 13, 2018, 10:22pm UTC](https://discourse.slimframework.com/t/middleware-withredirect/2531/2 "2018-07-13T22:22:30Z")

</div>

Browsers don’t expect a location header with a non 3xx response. I made a similar mistake. If the redirect is more important than the status code (which a user doesn’t see in a web app) then you will need to use a 3xx status code (like 302) or just remove the status code.

```php
return $response->withRedirect($this->router->pathFor('user.login'));

```

> <https://github.com/slimphp/Slim/issues/2355>

---

<div class="post-metadata">

**Author:** ![SVL](https://avatars.discourse-cdn.com/v4/letter/s/848f3c/32.png) [@SVL](https://discourse.slimframework.com/u/SVL)\
**Post date:** [July 14, 2018, 8:26am UTC](https://discourse.slimframework.com/t/middleware-withredirect/2531/3 "2018-07-14T08:26:40Z")

</div>

Thanks for the information tflight.
