亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

路由參數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,請教下這是什么原因呢 和老師的演示不一樣呀~謝謝


正在回答

2 回答

http://localhost:8888/laravel/public/user 不會報錯。但是為http://localhost:8888/laravel/public/user/ 就會301到http://localhost:8888/user? 了

0 回復 有任何疑惑可以回復我~

我也遇到同樣的問題了。

0 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

路由參數id為空時候跳轉到上層路徑,是什么原因?

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號