Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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

share|improve this question

1 Answer 1

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.

share|improve this answer
    
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. –  Andy 1 hour ago

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.