Reputation: 306
For example, when the entered url is
http://localhost:3000/course-details
it should always redirect to http://localhost:3000/courses
I remember there was a way to do that but I forgot it.
Upvotes: 0
Views: 3586
Reputation: 46604
@nuxtjs/router-extras is a nice library that will give you the possibility to make more customizable things router-wise, one of which is to redirect to another url.
/pages/course-details.vue
<router>
{
redirect: '/courses', // this syntax also works >> redirect: { name: 'courses' },
}
</router>
<template>
[...]
Otherwise, DengSihan's solution is a good vanilla solution.
Upvotes: 1
Reputation: 2997
you can handle this in the middleware of vue-page-component
pages/course-details.vue
<script>
export default{
middleware({ redirect }) {
return redirect('/courses');
}
}
</script>
this can be handled by nginx too
location = /course-details {
return 301 /courses;
}
Upvotes: 3