0

My application base url is http://localhost/abc/, when I define the angular routing, the angular removes the /abc from the base url and redirect the page to http://localhost/index.html. The Url should be http://localhost/abc/index.html.

See the following code for angular routing:

var routeConfig = function ($routeProvider, $locationProvider) {
    $routeProvider.
        when('/',{
            templateUrl: "index.html", // URL : http://localhost/abc/index.html
        }).
        when('/about',{
            templateUrl: "about.html", // URL : http://localhost/abc/about.html
        }).
        when('/contact',{
            templateUrl: "contact.html", // URL : http://localhost/abc/contact.html
        }).
      otherwise({
          redirectTo: "/"
      });
    $locationProvider.html5Mode(true);
}
routeConfig.$inject = ['$routeProvider', '$locationProvider'];

Please help to overcome this issue

1 Answer 1

3

That's normal. You need to add <base href="/abc" /> in your <head> tag. When you use html5Mode it will use this tag to set the base url.

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

Comments

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.