Welcome! Log In Create A New Profile

Advanced

Rewriting pages to re-rendered snapshots

July 01, 2013 06:26AM
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!
SubjectAuthorPosted

Rewriting pages to re-rendered snapshots

rootberryJuly 01, 2013 06:26AM

Re: Rewriting pages to re-rendered snapshots

Jonathan MatthewsJuly 01, 2013 06:46AM

Re: Rewriting pages to re-rendered snapshots

rootberryJuly 01, 2013 06:49AM

Re: Rewriting pages to re-rendered snapshots

Jonathan MatthewsJuly 01, 2013 07:44AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 99
Record Number of Users: 5 on December 17, 2014
Record Number of Guests: 154 on December 17, 2014
Powered by nginx    Powered by FreeBSD    PHP Powered    Powered by Percona     ipv6 ready