Reputation: 189
I have these routes defined:
const routes: Routes = [
{ path: 'Home', component: DashboardComponent },
{ path: '', redirectTo: '/Home', pathMatch: 'full' },
{ path: '**', component: NotFoundComponent },
];
and base href set like this:
<base href="/Site1/" />
When I navigate to localhost/Site1 I get the NotFound component, when I was expecting it to redirect to /Home
If I try localhost/Site1/ (with trailing forward slash) it does match the default route and redirects to /Home
How can I get the first URL to redirect properly?
Upvotes: 4
Views: 3206
Reputation: 908
More of a workaround than a fix I make it work by replacing :
{ path: '', redirectTo: '/Home', pathMatch: 'full' },
with :
{ path: '', component: DashboardComponent },
Upvotes: 0
Reputation: 41533
You add extra /
in your route definitions
const routes: Routes = [
{ path: 'Home', component: DashboardComponent },
///////////////////////////////////////////////////////////////////////
// removed the extra slash in the below line
///////////////////////////////////////////////////////////////////////
{ path: '', redirectTo: 'Home', pathMatch: 'full' },
{ path: '**', component: NotFoundComponent },
];
Upvotes: 1