When a search engine finds an AJAX-powered web application, it can't index such an app, because the search engine does not execute the complex JavaScript code. What the search engine wants is a static HTML.
In this recipe, we are going to learn how to make the search engine index the AJAX web application. We are going to deal mostly with Google, but we will also consider how to work with others.
The idea behind this recipe is that we can render the AJAX app into a static HTML page on the server and deliver it to a search engine spider via a proxy redirect.
To render JavaScript on the server, we are going to use the Node.js
and Phantom.js
files, which is a headless WebKit browser available as a Node module. We will also use a Node module named Seoserver that helps us to run Phantom.js
and output the result.
To distinguish the search engine spider from a regular client and use a proxy redirect to the Seoserver, we will use Apache's mod_rewrite
, mod_proxy...