1

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 ?

1 Answer 1

3

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

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

4 Comments

IIS. So switching to html5 mode is not enough, right ? What would the redirection look like in the above example ?
Correct. You will need to modify your web.config to redirect for you.
all is working fine now, I've done the url rewriting on the server side.
I have the same problem in nginx and nothing seems to work. base url is set, nginx is set, html5mode(true) is set, but it keeps giving out 404 errors when I refresh. If I go to base page, I can navigate, but I can no longer navigate to absolute URLs in the website.

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.