In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly shows you "laravel how to set redirection", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "laravel how to set redirection" this article.
Set redirect methods: 1, use "Route::get ()" and redirect () to redirect URL;2, use "redirect ()-> back ()" to redirect back to the previous page; 3, redirect to named route; 4, redirect to controller or controller with parameters; 5, use session data redirection, etc.
The operating environment of this tutorial: windows7 system, Laravel5 version, Dell G3 computer.
Several methods of Laravel redirection
1. Redirect URL
Routing:
Route::get ('itsolutionstuff/tags',' HomeController@tags')
Controller:
Public function home () {return redirect ('itsolutionstuff/tags');}
2. Redirect to the previous page
Public function home () {return back ();} / or public function home2 () {return redirect ()-> back ();}
3. Redirect to a named route
Routing:
Route::get ('itsolutionstuff/tags', array (' as'= > 'itsolutionstuff.tags',' uses' = > 'HomeController@tags'))
Controller:
Public function home () {return redirect ()-> route ('itsolutionstuff.tags');}
Redirect to a named route using parameters
Routing:
Route::get ('itsolutionstuff/tag/ {id}', array ('as'= >' itsolutionstuff.tag', 'uses' = >' HomeController@tags'))
Controller:
Public function home () {return redirect ()-> route ('itsolutionstuff.tag', [' id'= > 17]);}
4. Redirect to controller
Public function home () {return redirect ()-> action ('HomeController@home');}
Redirect to a controller with parameters
Public function home () {return redirect ()-> action ('App\ Http\ Controllers\ HomeController@home', [' id'= > 17]);}
5. Use session data redirection
We can also pass a flashed session message when using routing or url redirection in the controller method, as shown below.
Public function home () {return redirect ('home')-> with (' message', 'Welcome to PHP.cndirection');} above is all the content of the article "how to redirect laravel". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.