I have an angular application defined in my file index.html. Using angular -routing, I route the link with the name /erezto load the view using the template. It works inside the application - when I click the link /erezon the navigation bar on index.html, it works great. But when I go directly to my.site.com/erez in the address bar, it gives 404. I understand why this is so without server-side code, but is there a clean angular way to achieve direct URLs? my routing code:
var app = angular.module('labApp', ['ngRoute', 'angular.filter']);
app.config(function ($routeProvider, $locationProvider) {
$routeProvider.
when('/', {
templateUrl: 'index.html',
controller: 'mainCtrl'
}).
when('/erez', {
templateUrl: 'erez2.html',
controller: 'erezCtrl'
}).
otherwise({
redirectTo: '/'
});
$locationProvider.html5Mode(true);
});
source
share