Quantcast
Channel: Nginx Forum
Viewing all articles
Browse latest Browse all 53287

Rewriting pages to re-rendered snapshots

$
0
0
I have a very Javascript heavy website which is being served by nginx. It all works great, except Google is having trouble indexing me. I've made pre-rendered snapshots of all my pages using Phantomjs and these are stored in /snapshots (relative to my website's root).

I've been using this rewrite rule to detect the Google bot and serve it a snapshot:

location / {

if ($args ~ "_escaped_fragment_=") {
rewrite ^/(.*)$ /snapshots/$1.html break;
}

}

It works for all pages apart from the homepage. In the snapshots directory, the home page is called index.html, however the Google bot requests http://mysite.com/?_escaped_fragment_= when it wants the home page, which makes this rewrite rule return a 404.

How can I adapt this rule to return the index.html snapshot when / is requested?

Thanks!

Viewing all articles
Browse latest Browse all 53287


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>