I've created an app using AngularJS with GAE (Google App Engine – Java).
I want to convert it compatible with SEO.
index.html
<meta name="fragment" content="!" />
<base href="/">
and the body is loaded dynamically through <div ui-view></div>
.
app.js
$locationProvider.html5Mode(true);
The url works fine but when I refresh page I get 404 error.
Do you have any idea, what this causes?
for me, the fix to the the following line as the first line inside tag of you index (main) page:
Plus you need to configure IIS rewrite rule as following: (make sure you install iis rewrite extension first)
It's been a while since people were looking for this answer but I needed it today. I've made a working example with GAE, angularJS and ng-Route that has pretty formatted links.
Here is the link to the GitHub example
It should be helpful, official angular doc; https://github.com/angular-ui/ui-router/wiki/Frequently-Asked-Questions#how-to-configure-your-server-to-work-with-html5mode
Still I'll paste the relevent part here but I would advice to look at document.
ServerName my-app
Nginx Rewrites
Azure IIS Rewrites
Try adding below section in your grunt file liverload middleware section.
For the Java app running on GAE, you can use
URL rewrite filter
You'll find and XML file named urlrewrite.xml . Put all your routes in this xml, and configure it in a way so when you get a request like:
it will be redirected to
and your app will have time to be bootstrapped and fire the routing
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'shistory.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