Search code examples
angularjsseosingle-page-applicationhttp-status-codes

How do I return an http status code in an AngularJS single page application?


I have an AngularJS single page application used to display short-living resources, with an url like /auction/103. However, when the resource is no longer available, I wish to remove that page from the index of search engines. Thus, I need to return the status code 410 or 404 when a search engine crawler passes by.

However, how do I do this with a single page application where the page is not rendered on the server?


Solution

  • When you use Prerender for SEO, you can specify a meta tag which make Prerender return an http status code to the search engine crawler: https://prerender.io/server#http-headers.

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

    I have created a Plunker to illustrate this using AngularJS: http://plnkr.co/edit/Z0HdMd.