Integrate with IIS

Integrating Prerender.io with IIS doesn't need a middleware to be installed, you just need to add some well constructed URL rewrite rules to your server configuration.

Prerequisites:

Add the rules

  1. Navigate to IIS manager > Select your server > Sites > Select your site > Open URL Rewrite.
  2. Click "Add rule(s)..." on the right hand side and select "Blank rule".
  3. Name the rule (e.g. Prerender.io rewrite rule)
  4. Set up the "Match URL" section to look like this:
    1. Requested URL: Does Not Match the Pattern
    2. Using: Regular Expression
    3. Pattern: (\.js|\.json|\.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|\.svg)
    4. Check ignore case if your site URLs are case insensitive
  5. Add two rules in the "Conditions" section:
    1. Rule 1:
      1. Condition input: {HTTP_USER_AGENT}
      2. Check if input string: Matches the Pattern
      3. Pattern: googlebot|bingbot|yandex|baiduspider|facebookexternalhit|twitterbot|rogerbot|linkedinbot|embedly|quora\ link\ preview|showyoubot|outbrain|pinterest\/0\.|pinterestbot|slackbot|vkShare|W3C_Validator|whatsapp
      4. Check "Ignore case"
    2. Rule 2:
      1. Condition input: {QUERY_STRING}
      2. Check if input string: Matches the Pattern
      3. Pattern: _escaped_fragment_
    3. Set the "Logical grouping" to "Match Any".
  6. In the "Server Variables" section add your Prerender.io token to be forwarded to us:
    1. Click Add...
    2. Server variable name: HTTP_X_PRERENDER_TOKEN
    3. Value: [YOUR TOKEN]
    4. Check "Replace the existing value"
  7. Set up the "Action" section to match the following:
    1. Action type: Rewrite
    2. Rewrite URL: https://service.prerender.io/http://{HTTP_HOST}{REQUEST_URI}
    3. Check "Append query string"
    4. To get better logging, check "Log rewritten URL" (optional)
    5. Check "Stop processing of subsequent rules" (optional, this may also depend on your setup)

Notes:

  • Change the "Rewrite URL" to use https if your site enforces https.
  • This setup guide is just a template, your application may have special needs that need to be reflected in these rules.
  • this guide assumes that your IIS server is publicly accessible from the Internet. If you want to set this up for a local development environment, you need to run the open source Prerender component (https://github.com/prerender/prerender) locally on your computer, then use the URL of that service (e.g. http://localhost:3000) in point 7/b, replacing the https://service.prerender.io URL.
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.