Search code examples
javascriptangularjsurl-routing

Angularjs ng-view forbidden


i have the following routing:

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

however in my console i get the following:

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

Can anyone tell me why this is happening?

I can tell you that i have given rights to both the view and the folder my angular project is to both Read, Write, Delete


Solution

  • Have you got any authentication on server side? It seems like your php code is validating request and returning response with code 403 (probably, not authenticated). What is the result when you paste http://example.com/site/pages/views/Admins/index.php in browser?

    You can try attach controller, and then in controller make $http.get request and send proper data to backend to authenticate

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