Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Prerender.io IIS web.config
<?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="HTTP_X_PRERENDER_TOKEN" value="[...your token...]" />
</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="googlebot|bingbot|yandex|baiduspider|twitterbot|facebookexternalhit|rogerbot|linkedinbot|embedly|quora\ link\ preview|showyoubot|outbrain|pinterest|slackbot|vkShare|W3C_Validator" />
<add input="{QUERY_STRING}" pattern="_escaped_fragment_" ignoreCase="false" />
</conditions>
<action type="Rewrite" url="https://service.prerender.io/https://yourwebsite.com/{R:2}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
@thoop

This comment has been minimized.

Copy link
Owner Author

@thoop thoop commented Oct 18, 2018

You also need to add HTTP_X_PRERENDER_TOKEN to the Allowed Server Variables in IIS for the prerender token to be sent correctly to our prerender.io service.

@jaycincotta

This comment has been minimized.

Copy link

@jaycincotta jaycincotta commented Aug 30, 2019

There are also two other very important details we learned for using prerender.io with IIS:

  1. Install the ARR
  2. Check the ARR Enable Proxy flag otherwise, Rewrite to any external site will return 404
@jprakashpillai

This comment has been minimized.

Copy link

@jprakashpillai jprakashpillai commented Dec 27, 2019

hi
i had update my angular 8 website web.config file with the above rules but still my site pagesource not showing seo details
please help me regarding this.
my link is
http://oncloudinfotech.info/

Modified web.config

  <rule name="Angular Routes" stopProcessing="true">
    <match url=".*" />
    <conditions logicalGrouping="MatchAll">
      <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
      <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
    </conditions>
    <action type="Rewrite" url="/index.html" />
  </rule>
            <rule name="Prerender" stopProcessing="true">
                <serverVariables>
                    <set name="HTTP_X_PRERENDER_TOKEN" value="xxxxx" />
                </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="googlebot|bingbot|yandex|baiduspider|twitterbot|facebookexternalhit|rogerbot|linkedinbot|embedly|quora\ link\ preview|showyoubot|outbrain|pinterest|slackbot|vkShare|W3C_Validator" />
                    <add input="{QUERY_STRING}" pattern="_escaped_fragment_" ignoreCase="false" />
                </conditions>
                <action type="Rewrite" url="https://service.prerender.io/http://oncloudinfotech.info/{R:2}" />
            </rule>
</rules>
</system.webServer>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment