Last active

Embed URL


SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

Example Apache configuration for serving pre-rendered HTML from Javascript pages/apps using the Prerender Service at

View .htaccess
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /prerender-test/
# Virtual/pushState URIs (requests not matching an existing file get forwarded to index.html)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.html [L]
<IfModule mod_proxy_http.c>
# Enable prerendering for .html and directory index files
RewriteCond %{HTTP_USER_AGENT} googlebot|yahoo|bingbot|baiduspider [NC,OR]
RewriteCond %{QUERY_STRING} _escaped_fragment_|prerender=1
RewriteCond %{HTTP_USER_AGENT} !^Prerender
RewriteRule ^(.*\.html)?$$1 [P,L]
# Optionally add a ProxyPassReverse directive to ensure that 301/302 redirects
# issued by the prerender service are correctly forwarded to the client.
# Note that this must be located in your Apache config rather than .htaccess
# <IfModule mod_proxy_http.c>
# ProxyPassReverse /prerender-test/
# </IfModule>

Here is a more extensive list of some of the latest bot user agents sourced from



Thanks for the list @homerjam!

Hey guys, this isn't working for me. The request hits prerender but everything gets loaded into prerender as index.html and returns a blank html page: <html><head></head><body></body></html> (I am using User-Agent Switcher as a chrome extension to test behavior).

Before I switched to the pushState method, prerender was working with the "#!" method and I didn't need the following:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.html [L]


Hey again. Just wanted to let you guys know that I got things figured out but the fallback URL condition I listed above needed to be below the prerender proxy rewrite rule or else the page falls back to index.html before there is a chance to send the url to prerender.


Googlebot is starting to render Javascript so you may want to remove it from the user agents list (after testing in webmaster tools)


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.