kfomwa
Last Updated: February 25, 2016
·
5.081K
· clkao
F0cc4b511c06b73afb23beb5695a83d6

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.

Say Thanks
Respond

2 Responses
Add your response

9452
470b4f31c2e48aa4861a4e34774b83a1

So you're saying that if my repo uses a <username>.github.io/<repo> URL I'm out of luck?

over 1 year ago ·
19312
None

But does the server response status say 404? If so, that's not good.

over 1 year ago ·