Sign up ×
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute:

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

up vote 2 down vote accepted

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. – Andrei Sep 4 '14 at 0:37
    
No, the browser cannot support this from simple HTTP perspective. It has to be done serverside. – Niels Keurentjes Sep 4 '14 at 7:38

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.