I am devveloping a website using angularjs in which only 1 html page is present. I want to show the record by giving record Id from url as abc.in/1
. When I try to give this Id from url, it gives 404 not fount
error. But when I give abc.in#1
it works fine and displays the record.
I tried
angular.module('myApp', [
'ngRoute', 'ngResource', 'ngCookies',
'myApp.filters',
'myApp.services',
'myApp.directives',
'myApp.controllers',
'ui.bootstrap', 'ngAnimate', 'ngDragDrop' //'ngSanitize',
]).
config(['$routeProvider','$locationProvider', function ($routeProvider,$locationProvider) {
$routeProvider.when('/',
{
templateUrl: '/Login.html',
controller: 'LoginController'
});
$routeProvider.when('/:id',
{
templateUrl: '/Login.html',
controller: 'LoginController'
});
$routeProvider.otherwise({ redirectTo: '' });
if (window.history && window.history.pushState) {
$locationProvider.html5Mode({
enabled: true,
requireBase: false
});
}
in my app.js and in Login.html (which is default and only page in my application) is as-
<base href="/">
in head tag.
But this will only converts abc.in#1
to abc.in/1
when I try to refresh the page it will give error as-
HTTP Error 404.0 - Not Found
The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.
As per the given code I first need to give #1
in url and then it will converts into /
. But I want to give /1
initially. How to do that?