代码之家  ›  专栏  ›  技术社区  ›  Mihaela

AngularJs(404)页面重定向

  •  1
  • Mihaela  · 技术社区  · 7 年前

    如果我转到“siteURL/app/home”,主页会被加载,如果我转到“siteURL/app/wrongURL”,我会被重定向到404页面,但如果我尝试访问“siteURL/wrongURL”,我会出现以下错误:

    eNote:没有这样的文件或目录,lstat “/path\u to\u website\u folder/node\u modules/cloudcmd/errourl/”

    而不是被重定向到404页面。

    这是我写的代码:

    $urlRouterProvider.otherwise("/app/404");
    $stateProvider.state('app', {
        url: "/app",
        templateUrl: getPath('app.html')
    })
    .state('app.home', {
        url: "/home",
        templateUrl: getPath('app.home.html'),
        title: 'Home',
        keywords: "keywords",
        description: "description"
    })
    .state('app.404', {
            url: "/404",
            templateUrl: getPath('app.404.html'),
            title: '404'
    }); 
    

    1 回复  |  直到 7 年前
        1
  •  1
  •   Helen    7 年前

    你可以尝试添加 .state("otherwise", { url : '/404'...})