I was trying to remove '#' from URL.
I looked through a lot of example doing so. Almost all examples followed same 2 steps which I followed.
Step 1: Enable HTML5 mode
.config(function ($routeProvider,$locationProvider){
$routeProvider
.when('/', {
templateUrl: 'views/main.html',
controller: 'MainCtrl',
controllerAs: 'main'
})
.when('/products/',{
templateUrl:'views/HomeMain/products.html',
controller:'MainCtrl',
controllerAs:'main'
});
$locationProvider.html5Mode(true);
})
Step 2: Add basetag
<head>
<base href="/">
</head>
After following above mentioned steps I successfully removed '#' from the URL.
Whenever I navigate to 'products' page URL looks like
http://localhost:9001/products/
which is exactly what I want.
But, whenever I reload products page, this error is displayed in the browser window:
Cannot GET /products/
Why am I receiving this error? How do I handle this error?