Created
December 11, 2015 22:25
-
-
Save anonymous/60118c2fa81e2597d56a to your computer and use it in GitHub Desktop.
.htaccess for an AngularJS application to redirect all requests incoming from social networks and chat apps to Prerender.io
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<IfModule mod_headers.c> | |
RequestHeader set X-Prerender-Token "YOUR_ACCESS_TOKEN_HERE" | |
</IfModule> | |
<IfModule mod_rewrite.c> | |
RewriteEngine on | |
<IfModule mod_proxy_http.c> | |
RewriteCond %{HTTP_USER_AGENT} baiduspider|facebookexternalhit|twitterbot|rogerbot|linkedinbot|embedly|quora\ link\ preview|showyoubot|outbrain|pinterest|Slackbot|Slack-ImgProxy|Slackbot-LinkExpanding|Site\ Analyzer|SiteAnalyzerBot|Viber|Whatsapp|Telegram [NC,OR] | |
RewriteCond %{QUERY_STRING} _escaped_fragment_ | |
# Only proxy the request to Prerender if it's a request for HTML | |
RewriteRule ^(?!.*?(\.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))(.*) http://service.prerender.io/http://%{HTTP_HOST}/$2 [P,L] | |
</IfModule> | |
RewriteCond %{REQUEST_FILENAME} -s [OR] | |
RewriteCond %{REQUEST_FILENAME} -l [OR] | |
RewriteCond %{REQUEST_FILENAME} -d | |
RewriteRule ^.*$ - [NC,L] | |
RewriteRule ^(.*) /index.html [NC,L] | |
</IfModule> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment