0
votes

I've been working on an AngularJS/Rails app that must support IE9. From what I've read, I should set html5Mode to true in my AngularJS config, which will use the HTML5 History API for browsers that support it, and fall back to hashbang URLs for older browsers.

In the fantastic ng-book, it says:

"The back-end server will have to support URL rewriting on the server side. To support HTML5 mode, the server will have to make sure to deliver the index.html page for all apps. That ensures that our Angular app will handle the route."

What does that mean specifically? That I have to detect hashbang URLs in my server-side code and direct them to their non-hashbang equivalents?

So if my AngularJS content is at /v2/challenges/new (which appears as /#!/v2/challenges/new in IE9), that just means that the server-side code has to detect #! and serve the same content as /v2/challenges/new?

I also don't quite understand how falling back to hashbang syntax circumvents the IE9 issue?

1

1 Answers

1
votes

It means that if you're angular SPA app is hosted at /foo then any routes that get to your server directly, like if the user were to try and go to /foo/angular-route in their address bar or via bookmark then your web server will be responsible for returning the content at /foo and allow angular to handle the routing to /angular-route

With hash routing web servers basically ignore anything after the #. Basically to a web server /foo#/abc is handled the same as /foo and you need to configure your web server to function the same way without the #