如何路由 url 个具有多个线段的路段
How to route url sections with more than one segment
我需要根据前缀将 url 传递给不同的后端。比如下面的url
http://mysite/backend1/rest/of/url
需要使用 :backend 和 :restOfUrl 标记路由到 "BackendComponent",其中 :backend = 'backend1' 和 :restOfUrl = 'rest/of/url'
我试过了
{
path: ':backend/:restofurl',
component: BackendComponent
}
但是没有找到路线。我也简单地尝试过
path: 'Backend1/:restofurl'
但它仅在 :restofurl 没有正斜杠(即只有一个段)的情况下有效
这在 Angular 2+ 中可能吗?如果可以,怎么做?
类似的东西
{
path: 'Backend1',
component: BackendComponent,
children: [
{ path: '**', component: BackendComponent }
]
}
我需要根据前缀将 url 传递给不同的后端。比如下面的url
http://mysite/backend1/rest/of/url
需要使用 :backend 和 :restOfUrl 标记路由到 "BackendComponent",其中 :backend = 'backend1' 和 :restOfUrl = 'rest/of/url'
我试过了
{
path: ':backend/:restofurl',
component: BackendComponent
}
但是没有找到路线。我也简单地尝试过
path: 'Backend1/:restofurl'
但它仅在 :restofurl 没有正斜杠(即只有一个段)的情况下有效
这在 Angular 2+ 中可能吗?如果可以,怎么做?
类似的东西
{
path: 'Backend1',
component: BackendComponent,
children: [
{ path: '**', component: BackendComponent }
]
}