1

I either get a 403.14 - Forbidden error or a 404 - Not Found error when I try to navigate through the routes of my AngularJS application.

When I try to navigate to the base URL, I get a 403.

Example: http://localhost/Board.WebApp/ gives a 403.

For all other routes, I get a 403.

Example: http://localhost/Board.WebApp/template1 gives a 404.

What seems to be the problem? Here is my code:

default.html:

<!DOCTYPE html>
<html xmlns:ng="http://angularjs.org" xmlns="http://www.w3.org/1999/xhtml" id="app">
<head>
    <title>Board</title>
    <link rel="stylesheet" href="css/app.css" />
    <base href="/Board.WebApp/" />
</head>
<body ng-cloak>
    <section id="local-content" ng-view></section>
</body>
</html>

routes.js

function (module, amd) {
    'use strict';
    var mod = angular.module('routes', ['ngRoute']);
    mod.config(['$routeProvider', '$locationProvider', function ($routeProvider, $locationProvider) {

        $locationProvider.html5Mode({
            enabled: true,
            requireBase: true
        }); // for pushState routing support instead of # hash

        $routeProvider
            .when("/", amd.route(
            {
                templateUrl: 'views/home.html',
                controller: 'eventController',
                controllerUrl: 'app/controllers/eventController'
            }))
            .when("/template1", amd.route(
            {
                templateUrl: 'views/templates/template1.html',
                controller: 'eventController',
                controllerUrl: 'app/controllers/eventController'
            }))
    }]);
});
8
  • Could you please tell us what amd is? Commented Jan 21, 2016 at 16:41
  • There's a "dot" . in the view path, this is not allowed Commented Jan 21, 2016 at 16:48
  • 1
    Did you configure your rewrite engine for Html5Mode? If you don't, take a look at this question stackoverflow.com/questions/12614072/… Commented Jan 21, 2016 at 16:53
  • @Fals, the dot is permitted, it's the base path of the app Commented Jan 21, 2016 at 18:17
  • 1
    Just comment that lines where you configure html5Mode. it's set to false by default. Commented Jan 21, 2016 at 18:44

1 Answer 1

1

There is some server-side configuration required if you want to run in HTML5 mode: the server must rewrite links to the application entry point.

Sign up to request clarification or add additional context in comments.

1 Comment

can you elaborate more on that?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.