Created
September 28, 2015 21:52
-
-
Save Swimburger/4e49f84bbe3cc1514b77 to your computer and use it in GitHub Desktop.
Add prerender to Azure Website through web.config and applicationHost.xdt with HTML5 mode on
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
<?xml version="1.0"?> | |
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform"> | |
<system.webServer> | |
<proxy xdt:Transform="InsertIfMissing" enabled="true" preserveHostHeader="false" | |
reverseRewriteHostInResponseHeaders="false" /> | |
<rewrite> | |
<allowedServerVariables> | |
<add name="X-Prerender-Token" xdt:Transform="InsertIfMissing" /> | |
</allowedServerVariables> | |
</rewrite> | |
</system.webServer> | |
</configuration> |
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
<?xml version="1.0"?> | |
<configuration> | |
<system.webServer> | |
<rewrite> | |
<rules> | |
<!--# Only proxy the request to Prerender if it's a request for HTML--> | |
<rule name="Prerender" stopProcessing="true"> | |
<serverVariables> | |
<set name="X-Prerender-Token" value="YOURTOKEN" /> | |
</serverVariables> | |
<match url="^(?!.*?(\.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))(.*)" ignoreCase="false" /> | |
<conditions logicalGrouping="MatchAny"> | |
<add input="{HTTP_USER_AGENT}" pattern="baiduspider|facebookexternalhit|twitterbot" /> | |
<add input="{QUERY_STRING}" pattern="(.*)_escaped_fragment_=(.*)" ignoreCase="false" /> | |
</conditions> | |
<action type="Rewrite" url="http://service.prerender.io/http://{HTTP_HOST}{REQUEST_URI}" appendQueryString="false" /> | |
</rule> | |
<rule name="Redirect To Index" stopProcessing="true"> | |
<match url=".*" /> | |
<conditions> | |
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> | |
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> | |
</conditions> | |
<action type="Rewrite" url="/" /> | |
</rule> | |
</rules> | |
</rewrite> | |
</system.webServer> | |
</configuration> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment