Angular 301/404*.aspx和其他URL的角度路由
我用过角的-cli@1.2垂直和角度2.Angular 301/404*.aspx和其他URL的角度路由,angular,http-status-code-404,angular2-routing,angular-cli,Angular,Http Status Code 404,Angular2 Routing,Angular Cli,我用过角的-cli@1.2垂直和角度2. 我已将我的旧webform(asp.net和aspx页面)站点转换为angular站点,并在当前webform站点所在的同一域中托管。 因此,我所有的旧页面url都应该使用正确的重写规则重定向到我的angular站点 我想我的旧网站的网址,可能有或可能没有*.aspx在其网址(处理301),即从搜索引擎,他们可以击中我的角网站与*.aspx和其他旧网址。我想处理所有这些 我在应用程序中实现了路由规则,但在404重定向模块中遇到了问题。如果我尝试执行未知路
我已将我的旧webform(asp.net和aspx页面)站点转换为angular站点,并在当前webform站点所在的同一域中托管。 因此,我所有的旧页面url都应该使用正确的重写规则重定向到我的angular站点 我想我的旧网站的网址,可能有或可能没有*.aspx在其网址(处理301),即从搜索引擎,他们可以击中我的角网站与*.aspx和其他旧网址。我想处理所有这些 我在应用程序中实现了路由规则,但在404重定向模块中遇到了问题。如果我尝试执行未知路由,如 或 =>它将我重定向到主页,而不是404页 如果我能找到一种方法来执行404模块而不是主页,而不影响我当前的路由规则,我可以从那里处理旧的URL。但不幸的是,我在404中遇到了错误 任何一个有经验的人都会遇到这种需求。请引导我。我是新手 下面是我的应用程序中的路由代码 文件名:-app-routing.module.ts
import required files
const routes: Routes = [
{ path: 'not-found', loadChildren: './not-found/not-found.module#NotFoundModule' },
// { path: '', redirectTo: 'home', pathMatch: 'full' },
{
path: '',
loadChildren: './front-end/front-end.module#FrontEndModule' ,
},
{ path: '**', loadChildren: './not-found/not-found.module#NotFoundModule' },
];
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule { }
import required files
var childrens = [
{ path: '', loadChildren: './home/home.module#HomeModule' },
{ path: 'category', loadChildren: './category/category.module#VideosModule' },
{ path: 'product', loadChildren: './product/product.module#XpertModule' },
{ path: 'recovery', loadChildren: '../recovery/recovery.module#RecoveryModule' },
{ path: 'contactus', component: ContactusComponent },
];
const routes: Routes = [
{
path: '', component: FrontEndComponent,
children: childrens
}, {
path: ':language', component: FrontEndComponent,
children: childrens
},
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class FrontEndRoutingModule { }
文件名:-front-end-routing.module.ts
import required files
const routes: Routes = [
{ path: 'not-found', loadChildren: './not-found/not-found.module#NotFoundModule' },
// { path: '', redirectTo: 'home', pathMatch: 'full' },
{
path: '',
loadChildren: './front-end/front-end.module#FrontEndModule' ,
},
{ path: '**', loadChildren: './not-found/not-found.module#NotFoundModule' },
];
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule { }
import required files
var childrens = [
{ path: '', loadChildren: './home/home.module#HomeModule' },
{ path: 'category', loadChildren: './category/category.module#VideosModule' },
{ path: 'product', loadChildren: './product/product.module#XpertModule' },
{ path: 'recovery', loadChildren: '../recovery/recovery.module#RecoveryModule' },
{ path: 'contactus', component: ContactusComponent },
];
const routes: Routes = [
{
path: '', component: FrontEndComponent,
children: childrens
}, {
path: ':language', component: FrontEndComponent,
children: childrens
},
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class FrontEndRoutingModule { }
能给我点类似的吗
{path:'*.aspx',重定向到:'404'},
{路径:“404”,组件:NotFoundComponent}
我试过上面的那个,但没用
可能是我错过了一些路由规则。如果有,请告诉我