Angularjs ng视图被禁止

Angularjs ng-view forbidden

本文关键字:禁止 视图 ng Angularjs      更新时间:2023-10-28

我有以下路由:

  .config(['$routeProvider',
    function($routeProvider) {
        $routeProvider.
            when('/', {
                templateUrl: '/site/pages/views/Admins/index.php'
            }).
            otherwise({
                redirectTo: '/'
            });
    }])

然而,在我的控制台中,我得到了以下内容:

 GET http://example.com/site/pages/views/Admins/index.php 403 (Forbidden)

有人能告诉我为什么会发生这种事吗?

我可以告诉你,我已经授予视图和文件夹的权限,我的角度项目是Read, Write, Delete

您在服务器端进行过身份验证吗?您的php代码似乎正在验证请求并返回代码403的响应(可能未经过身份验证)。在浏览器中粘贴http://example.com/site/pages/views/Admins/index.php会得到什么结果?

您可以尝试连接控制器,然后在控制器中发出$http.get请求,并将正确的数据发送到后端以验证

.config(['$routeProvider',
    function($routeProvider) {
        $routeProvider.
            when('/', {
                templateUrl: 'basetpl.html',
                controller: 'MyController'
            }).
            otherwise({
                redirectTo: '/'
            });
    }])