Skip to content

Instantly share code, notes, and snippets.

@BorisPocatko
Forked from thoop/.htaccess
Last active April 22, 2020 19:49
Show Gist options
  • Save BorisPocatko/77f8f3812d05b934556854267a48150f to your computer and use it in GitHub Desktop.
Save BorisPocatko/77f8f3812d05b934556854267a48150f to your computer and use it in GitHub Desktop.
Clone of the Official prerender.io .htaccess for Apache.
# Change YOUR_TOKEN to your prerender token and uncomment that line if you want to cache urls and view crawl stats
# Change http://example.com (at the end of the last RewriteRule) to your website url
<IfModule mod_headers.c>
RequestHeader set X-Prerender-Token "YOUR_TOKEN"
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
<IfModule mod_proxy_http.c>
RewriteCond %{HTTP_USER_AGENT} googlebot|bingbot|yandex|baiduspider|facebookexternalhit|twitterbot|rogerbot|linkedinbot|embedly|quora\ link\ preview|showyoubot|outbrain|pinterest|slackbot|vkShare|W3C_Validator [NC,OR]
RewriteCond %{QUERY_STRING} _escaped_fragment_
# Only proxy the request to Prerender if it's a request for .html (skipping scripting extensions .xhtml,.shtml,.phtml,.jp,.cgi,.ppl,.pl,.perl,.php)
RewriteRule ^(?!.*?(\.xhtml|\.shtml|\.phtml|\.jp|\.cgi|\.ppl|\.pl|\.perl|\.php|\.js|\.css|\.xml|\.less|\.png|\.jpg|\.jpeg|\.gif|\.pdf|\.doc|\.txt|\.ico|\.rss|\.zip|\.mp3|\.rar|\.exe|\.wmv|\.doc|\.avi|\.ppt|\.mpg|\.mpeg|\.tif|\.wav|\.mov|\.psd|\.ai|\.xls|\.mp4|\.m4a|\.swf|\.dat|\.dmg|\.iso|\.flv|\.m4v|\.torrent|\.ttf|\.woff))(.*) http://service.prerender.io/http://example.com/$2 [P,L]
</IfModule>
</IfModule>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment