Using Slim we can use routes like:
$app->get('/path', function() {
include 'content.php';
});
We can also redirect to any other path of same domain like:
$app->get('/path2', function () use ($app) {
$app->redirect('/redirect-here');
});
But I want to redirect to some different domain and none of below is working:
$app->get('/feeds', function(){
$app->redirect('http://feeds.example.com/feed');
});
This shows blank page:
$app->get('/feeds', function() {
header("Location: http://feeds.example.com/feed");
});
In Slim 3, you should use the
withRedirect
method on theResponse
object:For Slim 2 only, you can do: