0

I'm trying to make a routing , it's working when I just clicking on links , but when I refresh the page , browser says not found ! I'm using html5mode , also when I set the # on url and search page manually it just works! what's the problem ? this is app.js :

app = angular.module("app", [ "ngRoute" ]);

app.config(function($locationProvider, $routeProvider) {
    $routeProvider.when("/", {
        templateUrl: "partials/index.html",
        controller: "mainCtrl"
    }).when("/index", {
        templateUrl: "partials/index.html"
    }).when("/person", {
        templateUrl: "partials/person.html",
        controller: "personCtrl"
    }).when("/person/:id", {
        templateUrl: "partials/personShow.html",
        controller: "personShowCtrl"
    }).when("/about", {
        templateUrl: "/partials/about.html"
    }).when("/contact", {
        templateUrl: "/partials/contact.html"
    }).when("/coworking", {
        templateUrl: "/partials/coworking.html"
    }).otherwise({
        redirectTo: "/partials/person.html"
    });
    $locationProvider.html5Mode(true);
});
2
  • Which web server are you using ? Apache ? Nginx ? you need to configure it to redirect 404 on index.html. Commented Apr 15, 2015 at 8:18
  • Can you create a plunkr ? Commented Apr 15, 2015 at 8:18

1 Answer 1

1

Here is excatly same question, anwsered by me:

tl;dr

You need a webserver, like Apache, Nginx or something based on Node.js and you need to redirect all your http calls to index.html

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

1 Comment

Thanks for quick answer , I'm using http-server , anyway do I have to use other webservers ?

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.