angularjs html5mode refresh page get 404

前端 未结 6 750
轮回少年
轮回少年 2020-12-08 21:53

I\'ve created an app using AngularJS with GAE (Google App Engine – Java).

I want to convert it compatible with SEO.

index.html

6条回答
  •  眼角桃花
    2020-12-08 22:16

    I'm sure you've already solved this, but for anybody else running into this issue:

    Basically AngularJS's $locationProvider.html5mode(true) makes use of HTML5's history.pushState(), which artificially changes the user's history and address bar URL without reloading the page. If you create a route (in Angular) for /about, but don't have any matching route on the server, you will run into the issue where reloading the page reveals the fact that it's not there on the server. The simplest solution is to mirror your entry point for your app (/index.html?) for all routes accessible by your app.

    See: https://stackoverflow.com/a/16570533/1500501

提交回复
热议问题