dongqin1861 2015-08-11 16:42
浏览 49

laravel:返回视图不从基于路线返回

I have an issue in Laravel routing. I am able to go to the following routes independently:

localhost/project/public/profile/profileSetup
localhost/project/public/thread/AddTrade

But, if I am on the route localhost/project/public/thread/AddTrade and if I click on the profile setup page link, I am redirected to localhost/project/public/thread/profile/profileSetup path instead of localhost/project/public/profile/profileSetup.

In my controller:

return view('profile.profileSetup')->with('data',$userProfile);

In my route:

Route::get('profile/profileSetup', array('uses'=>'ProfileController@ProfileSetup'));
  • 写回答

1条回答 默认 最新

  • duanlangwen9597 2015-08-11 17:48
    关注

    Always use named route to redirect.

    Define Route like this:

     Route::get('profile/profileSetup', array('uses' => 'ProfileController@ProfileSetup','as'=>'myroute'));
    

    and in you view:

    <a href="{{{ URL::route('myroute') }}}"></a>
    

    This will set the href attribute accordingly.

    评论

报告相同问题?