johnpapa / gulp-patterns

Playground for Gulp Recipes
500 stars 146 forks source link

Routing issue after the build process #96

Open mg-arrow opened 9 years ago

mg-arrow commented 9 years ago

I have the problem with going to the specific page of the application after the build was created and app was moved to the web server.

Example: App was moved to the server www.testserver.com to the folder angular. I've changed the base href attribute in the index.html file after the build:

We are trying to access it using http://www.testserver.com/angular/customers for example but getting 404 and route is not being hit at all even though all js files were loaded.

Is that a known issue ?

BTW If I try access the page using the pound sign reference, the app at least tries to load the correct route.

http://www.testserver.com/angular/#/customers

Thanks

Mikhail

igorlino commented 9 years ago

Ah, that's a webserver configuration problem. So angular only exists when the root has been loaded. Everything else maybe a virtual state/path. (depending which routing are relying on).

When you load the page with the http://www.testserver.com/angular/#/customers you are loading the root, the URL requested to the server is still sent as http://www.testserver.com/angular/ therefore it loads.

What you need to take care is on the server side (could be IIS, Apache, etc), rewrite the URL so that the browser can load it. For example: http://www.adamkdean.co.uk/enable-angularjs-html5-routing-on-iis

When you try to use http://www.testserver.com/angular/customers, the webserver, relying on standard routing will think: find angular/customers. But mmm, that does not exist, so you get the 404.

Beware also that the root, means the root of your application. Very simple examples are shown using the top root. Many real scenarios use not the top root but some xx/xx/xx hierarchy for one of the many SPA applications.

srameshr commented 9 years ago

I cant understand how the routing works here. I never hit the $urlRouterProvider.otherwise()

xts-velkumars commented 7 years ago

Hi, I have issue after build, i have deployed in IIS. when i refresh by page (or) copy and paste the URL its giving me 404 error. HTTP Error 404.0 - Not Found