0

I created a angularjs app using yeoman and below is my config

.config(function ($stateProvider, $locationProvider) {
    $stateProvider
      .state('state', {
        ....
      })

    $locationProvider.html5Mode(true);

  });

and inindex.html I have added <base href="/"> inside <head> as given in this solution

When I run the app for the first time using

grunt serve

Am able to navigate to all urls without #. But when I copy and paste the same url in different tab or refreshing any path its showing

Cannot GET /path_to_my_app

How to solve this?

Albert Einstein
  • 7,472
  • 8
  • 36
  • 71
VIK6Galado
  • 650
  • 14
  • 32
  • 1
    You need to serve the main HTML file through the server on the GET request so that for any URL the server first respond with the main index file so that the hashbang works on page reload – Ankit Agarwal Sep 25 '18 at 07:14
  • can't it be done form the angularjs app? – VIK6Galado Sep 25 '18 at 08:13
  • you need to fix routing manually **on the server**. Check your configuration file (e.g. [`.htaccess`](https://stackoverflow.com/questions/22739455/htaccess-redirect-for-angular-routes)) and add some rules that will resolve your routing – Aleksey Solovey Sep 25 '18 at 08:15
  • Possible duplicate of [Removing the fragment identifier from AngularJS urls (# symbol)](https://stackoverflow.com/questions/14771091/removing-the-fragment-identifier-from-angularjs-urls-symbol) – Philipp Maurer Sep 25 '18 at 08:31

0 Answers0