小编Met*_*rog的帖子

带有通配符的Laravel路线总是404

我刚刚开始使用Laravel,我非常喜欢路由的想法,但是我创建的任何带有通配符的路由都会回到Laravel 404路由.

这是我的路线文件:

# This loads fine
Route::get('hello', function(){
   return 'Hello!';
});

# This gives me a 404
Route::get('hello/(:any)', function ($name) {
    return "Welcome, $name.";
});

Route::get( array('/'), function()
{
    return View::make('home.index');
});

Event::listen('404', function()
{
    return Response::error('404');
});

Event::listen('500', function()
{
    return Response::error('500');
});
Run Code Online (Sandbox Code Playgroud)

我也试过any无济于事.

Route::any('hello/(:any)', function ($name) {
    return "Sup, $name?";
});
Run Code Online (Sandbox Code Playgroud)

关于我为什么得到404s的任何想法?

编辑: 我想我的PHP配置有点不稳定,没有正确处理类的别名或其他东西.添加一个将别名映射到类的辅助类可以在大多数情况下工作.

routing wildcard laravel

1
推荐指数
1
解决办法
769
查看次数

标签 统计

laravel ×1

routing ×1

wildcard ×1