Laravel 5和AngularJS删除'#';来自url


Laravel 5 and AngularJS removing '#' from url

我正在构建一个应用程序,我希望我的URL像my-domain.com/而不是my-domain.com/#/。因为我正在使用AngularJS构建SPA,所以我启用了$locationProviderhtml5Mode

然而,当我转到另一个页面,如my-domain.com/test(在我的$routeProvider配置中定义)时,我会得到laravel的错误页面。这不是我想要的,因为我想要AngularJS来处理这个路由。

我环顾四周,发现了类似的东西

App::missing(function($exception)
{
    return view('client/index');
});

遗憾的是,这在Laravel 5中不起作用。在研究了处理错误的新方法后,我决定测试新的异常处理程序,所以在我的App''Exceptions''Handler.php中,我做了以下操作:

public function render($request, Exception $e)
    {
        return view('client/index');
    }

不幸的是,这也不起作用,因为现在它呈现出一个空白页面。。。

有人知道怎么解决这个问题吗?这是我的angular ngroute配置代码:

client.config(['$routeProvider', '$locationProvider', function($routeProvider, $locationProvider){
    $routeProvider
        .when('/', {
            templateUrl: '/client_partials/Homepage.html'
        })
        .when('/test', {
            templateUrl: '/client_partials/Homepage.html'
        })
        .otherwise({
            redirectTo : '/'
        });
    $locationProvider.html5Mode(true);
    $locationProvider.hashPrefix('!');
}]);

这是路线:

Route::any('{path?}', function()
{
    return File::get(public_path() . '/angular.html');
})->where("path", ".+");