1

I appligize if this has already been asked already but I can not find any information about this.

I have an AngularJS application which will be accessed from the hard drive (not from a HTTP server) so the URL in the address will be something like file:///home/user/desktop/app.html)

I am not able to get HTML5-mode URL routing to work. I am using UI-routing module for AngularJS, and whenever I go to file://..../app.html/somepage), the routing does not work. If I set HTML5 mode to false in $locationProvider, and then I go to file://.../app.html#/somepage then it does work.

So is it possible to do? Can someone show me a example where file://-hosted app can with with a URL like file:///myapp.html/somepage ??

Thanks

1 Answer 1

2

No. The file:// pseudo-protocol directly queries the local filesystem. For 'fancy' URLs like /myapp.html/somepage to work you need to have a mechanism in between, like Apache's mod_rewrite or FallbackResource which handles those fancy URLs. Since those don't work on the file system, you're out of luck.

Install something like XAMPP to test websites locally through a webserver that is capable of these things.

Sign up to request clarification or add additional context in comments.

2 Comments

Niels, please clarify one thing. Is an in-between mechanism like mod_rewrite or FallbackResource (or some other url-rewriting mechanism) the ONLY way to get the pretty URLs to work with AngularJS in HTML5 mode? I thought that this is supported on a Browser level and should work if the user is using a modern browser? docs.angularjs.org/guide/$location does say "requires server-side configuration" for html5 mode.
No, the browser cannot support this from simple HTTP perspective. It has to be done serverside.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.