javascript - $stateprovider throws 404 if i visit link directly from url bar -


i'm using ui.router angularjs , came across strange behavior. if click trough page works expected, links changing, templates loading, if visit specific page directly (other www.myapp.com) 404 page not found

this app.js

var app = angular.module('app', ['ui.router', 'ui.bootstrap']);  app.config(function($stateprovider, $urlrouterprovider,$locationprovider){     $urlrouterprovider.otherwise("/dashboard");     $stateprovider         .state('dashboard', {             url: "/dashboard",             templateurl: "app/templates/dashboard/dashboard.html",             controller: 'dashboardctrl'         })         .state('locations', {             url: "/locations",             templateurl: "app/templates/locations/locations.html",             controller: 'locationsctrl'         })         .state('locations.add_location', {             url: "/locations/add_location",             templateurl: "app/templates/locations/add_location.html",             controller: 'addlocationctrl'         });     $locationprovider.html5mode(true); }); 

explained in pictures

i visit www.myapp.com, page renders enter image description here
click on locations, working enter image description here
can click on dashboard link again , work

but if press f5 or copy paste link in url bar of browser, 404 enter image description here

why happening. im missing. if need additional informations, please let me know , provide.

that's because apache tries serve file location in www root directory. it's not possible because have got spa app without subpages. have force apache web server rewrite locations , serve index.html page (main page). found helpful gist that: https://gist.github.com/santthosh/7dabf08fa3859361ef1e


Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -