ngRoute not working when refreshing the page

1.7k Views Asked by At

The website working fine with ngRoute on http://www.athimannil.com/ but unfortunately page http://www.athimannil.com/about not working when refresh URL :(

is there anything extra need to add in the JavaScript code ?

var app = angular.module('app',['ngRoute']);
    app.config(function($routeProvider, $locationProvider) {
        $locationProvider.html5Mode(true);
        $routeProvider
            .when('/', {
                templateUrl: 'home.html',
                controller: 'homecontroller'
            })
            .when('/about', {
                templateUrl: 'about.html',
                controller: 'aboutController'
            })
            .when('/portfolio', {
                templateUrl: 'portfolio.html',
                controller: 'portfolioController'
            })
            .when('/contact', {
                templateUrl: 'contact.html',
                controller: 'contactController'
            })
            .when('/cv', {
                templateUrl: 'cv.html',
                controller: 'cvController'
            })
            .otherwise({
                redirectTo: '/'
            });
    });

.htaccess

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
1

There are 1 best solutions below

0
On

by default angular uses routes like .../#/...

if you want to remove that you need some server configurations

AngularJS routing without the hash '#'