首页 > 解决方案 > Angular Route 部分通配符

问题描述

当一个链接像这样进来时:mysite.com/_/somethingThatChangesRandomly

我希望将其重定向到登录页面,因此规则是“路径以_开头”:

{
    path: '_/**', redirectTo: "login"
}

但我收到一个错误:

Cannot match any routes. URL Segment: '_/somethingThatChangesRandomly'

标签: angularroutes

解决方案


{
 path: '_',
 children: [
   {
     path: "**",
     redirectTo: "/login"
   }
 ]
}

推荐阅读