can't figure out how to create nested routes with route redirects. #1996
-
I'm trying to figure out how to render a route like this When I go to that route, I expect all pieces from each subpath to be rendered. So with the analogy, it should render a house with a garage and inside that garage is a car. That's fine and all but I also want to prevent people from going to the How can I get this working with file based routing? Sorry for the weird analogy but hope it makes sense and thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
One option you can consider is in the beforeLoad of your garage route, adding a redirect. for example beforeLoad({ location }) {
if (location.pathname === "/house/garage")
throw redirect({ to: "/house/garage/car" })
} Alternatively, if garage is simply an outlet, then you should probably show a 404 page at that route instead of having garage as a parent of car. (Note, I have not extensively used file based routing so my assumption here may be incorrect) but at the moment, it sounds like you have
When really you might want something more like
My understanding based on the File-based routing docs is that you can do this using a folder structure like follows.
|
Beta Was this translation helpful? Give feedback.
One option you can consider is in the beforeLoad of your garage route, adding a redirect. for example
Alternatively, if garage is simply an outlet, then you should probably show a 404 page at that route instead of having garage as a parent of car. (Note, I have not extensively used file based routing so my assumption here may be incorrect) but at the moment, it sounds like you have
When really you might want something more like
My understanding based on the File-based routing docs is that you can do this using a folder str…