使用Slim Framework重定向

I have the following code:

$app->get('/category/:name', function($name){
  //the render files are found under the templates folder
header('Location: searchPage.php?crs_category=$name');
});

The problem is that when I type /category/business its just lands on blank page. I do not want to render the page because I can't exactly render searchPage.php?crs_category because it is view as a template and there's a work around to include to variable. I just want to go directly to that page while keeping the url clean. Essentially redirect to this page in the background with the url remaining that.

Thanks in advance.

Assuming you're using Apache as a webserver, couldn't you just rewrite the URL in .htaccess:

RewriteRule ^category/(.*)$ searchPage.php?crs_category=$1 [L,NC,QSA]

..or if you want a real redirect

RewriteRule ^category/(.*)$ searchPage.php?crs_category=$1 [L,NC,R=301]

PS If you insist on doing it in Slim, you could try

$app->get('/category/:name', function($name) use ($app) {
    $app->response->redirect('/searchPage.php?crs_category='.$name, 303);
});

source: http://docs.slimframework.com/response/helpers/#redirect