Named Route and Routes Group Laravel 11
// Below is Named Routes declaration:
Route::get("/test", function () {
return view("about");
})->name("aboutus");
Route::redirect("/about", "/test");
Route::get("/posttest", function () {
return view("post");
})->name("mypost");
Route::redirect("/post", "/posttest");
Route::get("/thispost", function () {
return view("firstpost");
})->name("firstpostishere");
// Making Routes Group as shown below :
Route::prefix("page")->group(function () {
Route::get("/about", function () {
return "<h1>About Page</h1>";
});
Route::get("/gallery", function () {
return "<h1>Gallery Page</h1>";
});
Route::get("/post/firstpost", function () {
return "<h1>First Post Page</h1>";
});
});
// If any page is not present then default error 404 will not show but fallback function will call instead of "404 | NOT FOUND".
Route::fallback(function () {
return "<h1>Page Not Found.</h1>";
.png)
.png)
Comments
Post a Comment