【发布时间】:2018-05-12 21:30:41
【问题描述】:
在生产模式下重定向我的应用时遇到问题。当我有 url http://server.com/projectname/dashboard 时,服务器响应 IIS 错误页面 404。我必须使用 http://server.com/projectname 打开应用程序,然后单击链接,例如:
<a [routerLink]="'dashboard'">Dashboard</a>
在 html 中我有 <base href="./">,这是我的路由器:
const appRoutes: Routes = [
{ path: '', redirectTo: 'dashboard', pathMatch: 'full', canActivate: [AuthGuard] },
{ path: 'dashboard', component: DashboardComponent, canActivate: [AuthGuard]},
{ path: '400', component: ErrorComponent, canActivate: [AuthGuard] },
{ path: '401', component: ErrorComponent, canActivate: [AuthGuard] },
{ path: '404', component: ErrorComponent, canActivate: [AuthGuard],
{ path: '**', redirectTo: '/404' }
]
@NgModule({
imports: [
RouterModule.forRoot(appRoutes)
]
})
在开发模式下,我有 url http://localhost:4200/dashboard,我应该重定向。开发中是 url localhost:4200/dashboard 而生产中是 server.com/appname/dashboard 会不会有问题?
【问题讨论】:
标签: angular angular2-routing angular2-template angular5 angular4-router