我使用
PHP 5.4 RC5,并通过终端启动服务器
php -S localhost:8000
目前使用Aura.Router,并在根目录下我有index.php文件的代码
$map = require '/Aura.Router/scripts/instance.php';
$map->add('home', '/');
$map->add(null, '/{:controller}/{:action}/{:id}');
$map->add('read', '/blog/read/{:id}{:format}', [
'params' => [
'id' => '(\d+)',
'format' => '(\.json|\.html)?',
],
'values' => [
'controller' => 'blog',
'action' => 'read',
'format' => '.html',
]
]);
$path = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
$route = $map->match($path, $_SERVER);
if (! $route) {
// no route object was returned
echo "No application route was found for that URI path.";
exit;
}
echo " Controller : " . $route->values['controller'];
echo " Action : " . $route->values['action'];
echo " Format : " . $route->values['format'];
对http:// localhost:8000 / blog / read / 1的请求按预期工作.
但是当一个点json或点html像http:// localhost:8000 / blog / read / 1.json,http:// localhost:8000 / blog / read / 1.html请求来时,php抛出
Not Found
The requested resource /blog/read/1.json was not found on this server.
当我使用内置的php服务器运行服务器时,我在哪里可以修复不抛出html和json文件找不到错误?
或者我想去安装apache并启用mod重写和东西?