angularjs html5Mode on github pages
angularjs provides html5Mode, which makes your app use pushstate-based URL instead of hashtags. However this requires server side support, since the generated urls need to be rendered properly as well.
This actually works fine with github pages' custom 404 pages, though it's only available for custom domain enabled pages.
Simply copy index.html to 404.html, and add this to your app:
angular.module('app', []).config(function($locationProvider) {
$locationProvider.html5Mode(true);
});
Note that if you are on angular 1.1.5, make sure you set <base href="/">
for html5Mode to work properly.
Written by Chia-liang Kao
Related protips
2 Responses
So you're saying that if my repo uses a <username>.github.io/<repo> URL I'm out of luck?
over 1 year ago
·
But does the server response status say 404? If so, that's not good.
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Html5
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#