AngularJS SEO Page 404 Title Status Code

We are working on a project that uses Symfony2 + AngularJS. Each of them is in a different domain (api.domain for Symfony2 and www.domain for the Angular project).

Now we are focusing on the SEO parts. We use Prerender.io to create static snapshots to serve as a good HTML Raw page for crawlers.

But the problem is serving the 404 page on Angular:

$urlRouterProvider .otherwise('/404'); 

The fact is that we are redirecting a non-existent page to our "404" page with a heading status code of 200, which is very bad for SEO purposes ...

Since AngularJS is not capable of generating, we have already tried 2 things:

1. Use redirection with htaccess / Apache:

  RedirectMatch 404 "/404" 

2. Call the web service that returns us 404 error:

 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <html> <head> <title>404 Not Found</title> </head> <body> <h1>Not Found</h1> <p>The requested URL /do-not-access was not found on this server.</p> </body> </html> 

And for the AngularJS side, we tried to reset the header status code without success:

 return $http.get(ENV.apiEndpoint + '/do-not-access'); 

None of this worked for us ...

We are also about using the second page "404". The idea was to redirect our first 404 page to this second 404 page via htaccess with a 404 status code, but we believe that this will not work due to AngularJS internal redirection:

 200 -> 301 -> 404 

PS: I found: AngularJS html5mode and hard 404 , which says: "We must configure our server to make a routing exception for your 404 user page," but we really have no idea how to do this ...

Are we focusing badly?

Is there another option?

How can we handle this?

Any ideas?

+2
angularjs seo apache .htaccess
source share
1 answer

It seems that prerender.io offers a way to handle the status of the http header .

For example, for a 404 page, we just need to add this meta tag to our main tag :

 <meta name="prerender-status-code" content="404"> 

Docs: https://prerender.io/documentation/best-practices

+3
source share

All Articles