# Slim doesn't redirect

**URL:** <https://discourse.slimframework.com/t/slim-doesnt-redirect/365>\
**Category:** Questions\
**Created:** [June 4, 2016, 6:15pm UTC](https://discourse.slimframework.com/t/slim-doesnt-redirect/365 "2016-06-04T18:15:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![zzanette](https://avatars.discourse-cdn.com/v4/letter/z/278dde/32.png) [@zzanette](https://discourse.slimframework.com/u/zzanette)\
**Post date:** [June 4, 2016, 6:15pm UTC](https://discourse.slimframework.com/t/slim-doesnt-redirect/365/1 "2016-06-04T18:15:03Z")

</div>

Hi,  
I just begginer in Slim framework V2 and in my actual new project i’m trying to do a redirects like this:

```
$app->get('/', function() use ($app) {
    $app->render('home.php');
})->name('home');

$app->get('/flash', function() use ($app) {

    $app->flash('registerFlash', 'You have registred!!!');
    $app->response->redirect($app->urlFor('home'), 301);
})->name('flash');

```

But the Slim doesn’t redirect. I try to use the **$app-\>redirect($app-\>urlFor(‘home’), 301);** function as discribed in [http://docs.slimframework.com/routing/helpers/](http://docs.slimframework.com/routing/helpers/) but doesn’t work too.  
Any idea, whats wrong with my redirects?

Thanks!

---

<div class="post-metadata">

**Author:** ![TheLobos](https://avatars.discourse-cdn.com/v4/letter/t/e9bcb4/32.png) [@TheLobos](https://discourse.slimframework.com/u/TheLobos)\
**Post date:** [June 4, 2016, 7:26pm UTC](https://discourse.slimframework.com/t/slim-doesnt-redirect/365/2 "2016-06-04T19:26:35Z")

</div>

I don’t know what’s wrong with your code, as I’ve never used Slim V2, but if you’re starting a new project, my strong suggestion would be to go with Slim V3. There’s really no point in using an outdated version of the framework for a new project.

---

<div class="post-metadata">

**Author:** ![zzanette](https://avatars.discourse-cdn.com/v4/letter/z/278dde/32.png) [@zzanette](https://discourse.slimframework.com/u/zzanette)\
**Post date:** [June 5, 2016, 3:24pm UTC](https://discourse.slimframework.com/t/slim-doesnt-redirect/365/3 "2016-06-05T15:24:05Z")

</div>

Thaks for your suggestion! I will change to the version 3.

I discover a wrong require file in my code.

---

<div class="post-metadata">

**Author:** ![TheLobos](https://avatars.discourse-cdn.com/v4/letter/t/e9bcb4/32.png) [@TheLobos](https://discourse.slimframework.com/u/TheLobos)\
**Post date:** [June 5, 2016, 7:28pm UTC](https://discourse.slimframework.com/t/slim-doesnt-redirect/365/4 "2016-06-05T19:28:04Z")

</div>

Not sure what you’re doing, but given that Slim is all autoloader based, you should not need any require statements for classes. The only requires I have are the ones for settings, routes, dependencies and middleware. Anything else is loaded by the autoloader.
