【发布时间】:2014-04-04 06:23:16
【问题描述】:
让我的应用程序在 localhost 上运行,路径是:localhost/silex/web/index.php,在下面的代码中定义路由,我希望访问localhost/silex/web/index.php/redirect 重定向我到localhost/silex/web/index.php/foo 并显示'富'。相反,它会将我重定向到localhost/foo。
我是 Silex 的新手,也许我弄错了。有人可以解释问题出在哪里吗?这是正确的行为,它应该重定向到绝对路径吗?谢谢。
<?php
require_once __DIR__.'/../vendor/autoload.php';
use Symfony\Component\HttpFoundation\Response;
$app = new Silex\Application();
$app['debug'] = true;
$app->get('/foo', function() {
return new Response('foo');
});
$app->get('/redirect', function() use ($app) {
return $app->redirect('/foo');
});
$app->run();
【问题讨论】: