2014-05-22 27 views
0

在控制器如果我寫重定向到::錯誤NotfoundHttpException

return Redirect::to('admin/createpost'); 

重定向時,它拋出NotfoundHttpException。但如果我只用

return Redirect::to('createpost') 

它工作正常。我猜它通過這條路線

Route::get('createpost', '[email protected]'); 

在第一種情況下,爲什麼它會拋出錯誤訪問我的預期視圖(管理/ createpost)。什麼是正確的使用方法Redirect::to

回答

1

Redirect::to是你想要去的確切網址。

所以,如果你想使你的路線 'admin/createpost' 變化

Route::get('createpost', '[email protected]'); 

Route::get('admin/createpost', '[email protected]'); 
+0

所以使用重定向到::( '管理/ createpost'),我應該有途徑'管理/ createpost'?當我改變,我得到錯誤,沒有命名的路線存在。所以我使用了名稱路由。仍然有MethodNotAllowedHttpException錯誤。我命名的路線'Route :: get('admin/createpost',array('as'=>'admin/createpost','uses'=>'AdminController @ getCreate')); \t Route :: post('admin/createpost',array('as'=>'admin/createpost','uses'=>'AdminController @ postCreate')); '。 – kishan