I am getting a served the 404 page whenever I :
1.) refresh any page on my Angularjs site (besides the root page)
or
2.) click Back to go from a 404 page to the root page (the root page will be a 404)
Here is my .config()
code
'use strict';
angular.module('mmApp', ['ngResponsiveImages'])
.config(function ($locationProvider, $routeProvider) {
$locationProvider.html5Mode(true);
$locationProvider.hashPrefix = '!';
$routeProvider
.when('/', {
templateUrl: '/views/design.html',
controller: 'MainCtrl'
})
.when('/about', {
templateUrl: '/views/about.html',
controller: 'MainCtrl'
})
.when('/contact', {
templateUrl: '/views/contact.html',
controller: 'MainCtrl'
})
.otherwise({
redirectTo: '/'
});
});
I have come across this similar question but do not quite understand the answers or how to implement them.
AngularJS - Why when changing url address $routeProvider doesn't seem to work and I get a 404 error
The accepted answer says to setup Apache to reconfigure all paths to the root. My site is on Github Pages. I have a .htaccess
file in my gh-pages
repo but I have no idea how to configure it to send all paths to the root.
The answer says another thing to consider is using the <base>
element like <base href="/" />
but where would I place that? In my index.html
? If so at the top or bottom of that file? Also, would I just leave the href
value to /
?