IIS Integration
  • 19 May 2023
  • 2 Minutes to read
  • Contributors
  • Dark
  • PDF

IIS Integration

  • Dark
  • PDF

Article Summary

Integrating Prerender.io with IIS doesn't require a middleware installation; simply add some well-constructed URL rewrite rules to your server configuration.


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:
      • Condition input: {HTTP_USER_AGENT}
      • Check if input string: Matches the Pattern
      • Pattern: googlebot|bingbot|yandex|baiduspider|facebookexternalhit|twitterbot|rogerbot|linkedinbot|embedly|quora\ link\ preview|showyoubot|outbrain|pinterest\/0\.|pinterestbot|slackbot|vkShare|W3C_Validator|whatsapp|redditbot|applebot|flipboard|tumblr|bitlybot|skypeuripreview|nuzzel|discordbot|google\ page\ speed|qwantify|bitrix\ link\ preview|xing-contenttabreceiver|chrome-lighthouse|telegrambot|google-inspectiontool
      • Check "Ignore case"
    2. Rule 2:
      • Condition input: {QUERY_STRING}
      • Check if input string: Matches the Pattern
      • 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/https://{HTTP_HOST}{REQUEST_URI}
    3. Uncheck "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)


  • Change the "Rewrite URL" to use HTTP if your site enforces HTTP.
  • If you have special encoded characters in your URL
    • Use Rewrite URL: https://service.prerender.io/http://{HTTP_HOST}{UNENCODED_URL}
    • Set useOriginalURLEncoding to 'false'. To set the flag, start IIS Manager, select Configuration Editor, and go to the section system.webServer/rewrite/rules.
  • 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. Suppose you want to set this up for a local development environment. In that case, 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.

Was this article helpful?

What's Next