路由參數(shù)id為空時(shí)候跳轉(zhuǎn)到上層路徑,是什么原因?
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/時(shí)候,參數(shù)為空的時(shí)候自動跳轉(zhuǎn)到了http://localhost:8888/user,服務(wù)器返回:
Not Found
The requested URL /user was not found on this server.
調(diào)試環(huán)境為MAMP,請教下這是什么原因呢 和老師的演示不一樣呀~謝謝
2017-02-06
http://localhost:8888/laravel/public/user 不會報(bào)錯(cuò)。但是為http://localhost:8888/laravel/public/user/ 就會301到http://localhost:8888/user? 了
2017-02-06
我也遇到同樣的問題了。