I have an AngularJS web application:
I am using ng-router
, so all my pages have # in the url.
I want google to index my /#/forum page
.
This stackoverflow answer explains how to make AngularJS indexed by Google:
To generate real URLs in Angular, rather than # prefixed ones, set HTML5 mode on your $locationProvider object: $locationProvider.html5Mode(true);
Since you are using real URLs, you will need to ensure the same template (plus some precomposed content) gets shipped by your server for all valid URLs. How you do this will vary depending on your server architecture.
I followed this tutorial to make it work.
As mentioned in the article above, my server should respond to /forum
requests, so I redirect the request from /forum
to /#/forum
and use HTML5 to change the url back to /forum
. This works as expected.
My problem is with Fetch as Google. When I try to fetch the page /forum
as Google, it tells me that this page is redirected to /#/forum
(obviously). and when I try to fetch /#/forum
, Google ignores the # and everything after it and fetches /
.
How do I fetch my /forum
page?
And how do I make sure Google indexes it?