路由參數id為空時候跳轉到上層路徑,是什么原因?
Route::get('user/{id?}',?function?($id?=?null)?{ ????//id?is?null?,?and?display?list?of?users ????if?($id?==?null)?return?'User?List'; ????//id?is?not?null?,?display?the?user's?info ????else?return?'User-'.$id; });
訪問http://localhost:8888/laravel/public/user/時候,參數為空的時候自動跳轉到了http://localhost:8888/user,服務器返回:
Not Found
The requested URL /user was not found on this server.
調試環境為MAMP,請教下這是什么原因呢 和老師的演示不一樣呀~謝謝
2017-02-06
http://localhost:8888/laravel/public/user 不會報錯。但是為http://localhost:8888/laravel/public/user/ 就會301到http://localhost:8888/user? 了
2017-02-06
我也遇到同樣的問題了。