Sam
Sam

Reputation: 14586

angularjs html5mode not working

If I don't use the html5mode, everything works fine. But when I activate it I keep getting 404 error on every request.

Here's the relevant code:

$urlRouterProvider.otherwise('/404');
$locationProvider.html5Mode(true);

    $stateProvider
        .state('404', {
            url: '/404',
            views: {
                '': {
                    templateUrl: '404.html'
                }
            }
        });

and I use the ui-route state provider :

$stateProvider.state('mandates', {
            url: '/domiciliations/mandats',
            views: {
                '': {
                    templateUrl: 'directDebit/views/mandates.html',
                    controller: 'mandates.ctrl',
                },
                'menu-action': {
                    templateUrl: 'directDebit/views/menu/menu.mandates.html',
                    controller: 'menu.mandates.ctrl'
                }
            }
        })

So if I try to access mydomain/app/domiciliations/mandats, I get a 404. If I don't use html5 mode, then requesting mydomain/app/#/domiciliations/mandats.

Any idea what I should change ?

Upvotes: 1

Views: 1130

Answers (1)

Brian Lewis
Brian Lewis

Reputation: 5729

You need to make sure your server is setup to redirect all requests to your index/app. What server are you running?

Upvotes: 3

Related Questions