我正在使用Laravel 5和Angular。如何使Laravel 5重定向到沒有散列(#)的Angular路線?
默認情況下,Angular將/#/
添加到URL中。
我不喜歡那/#/
所以我使用Angular的$locationProvider.html5Mode(true);
刪除它。
現在每當我試圖訪問一個角度URL,Laravel拒絕重定向我,相反,它會導致一個錯誤NotFoundHttpException
說:
對不起,您要找的頁面無法找到。
NotFoundHttpException在RouteCollection.php線161:
這是很符合邏輯,因爲路由沒有在Laravel的路線文件中定義。
如何解決這個問題?
更多詳細信息:
- 當我訪問
http://whatever.app/#/dashboard/home
一切工作正常(laravel知道這是角路線,然後角擺脫#,這樣的URL成爲http://whatever.app/dashboard/home
沒有一個錯誤)。 - 當我訪問
http://whatever.app/dashboard/home
Laravel顯示錯誤NotFoundHttpException
。