Redirecting Old Paths
Part of the Routing and State section of Coddy's Vue journey. Lesson 26 of 55.
A redirect preserves an old entry point while selecting a canonical destination. The old record does not need its own rendered component because navigation resolves to the target record.
{path:'/old-library',redirect:{name:'library'}}
{path:'/library',name:'library',component:Library}The resulting current path is the destination path. A function redirect can inspect the incoming location and deliberately carry query fields into the new destination. Use an alias instead only when you intend a different matching URL to remain visible; this lesson changes the location through a redirect.
Challenge
MediumSupport the old path /agenda by redirecting it to the named calendar route at /calendar. The destination must render Activity calendar and the route readout must show the canonical path, including after leaving for Help and using the old link again.
Keep the supplied route readout and bootstrap files.
Try it yourself
<!doctype html><html><head><meta charset="UTF-8"><title>Routing practice</title></head><body><div id="app"></div><script type="module" src="./main.js"></script></body></html>This lesson includes a short quiz. Start the lesson to answer it and track your progress.
All lessons in Routing and State
4Query State
Reading Query ValuesCommitting Search QueriesPreserving Other FiltersNormalizing Query NumbersRecap: Catalog Filters2Navigation Actions
Navigation from HandlersReplacing HistoryHistory TravelCurrent Navigation LinksRecap: Save and Review5Nested Layouts
Parent and Child OutletsDefault Child ViewsRelative Child PathsAncestor Navigation StateRecap: Library Workspace8Store Design
Setup Store StructurePatching Related StateResetting Store StateComposing Related StoresRecap: Trip Pack11Workshop Planner Project
Planner RoutesShared Reservations3Dynamic Routes
Path ParametersReactive Route SelectionRoute Parameters as PropsMissing Route RecordsRecap: Equipment Routes6Route Policies
Redirecting Old PathsUnmatched PathsRoute MetadataCancelling NavigationRecap: Club Destinations