- Print
- DarkLight
- PDF
Integrating Prerender.io with IIS can be achieved through URL rewrite rules in server configuration, without requiring middleware installation.
The Azure App Services URL rewrite rules do not support specifying a different domain. Because fo this the Integration is different on this platform.
Please see the guide on the Azure IIS intgeration here.
Video guide
The location of the Prerender token has changed. You can find it under the Security and Access menu under Prerender Token.
The required modules can be downloaded from the links below:
https://www.iis.net/downloads/microsoft/url-rewrite
https://www.iis.net/downloads/microsoft/application-request-routing
The required patterns and other strings can be found in the text guide below.
Text guide:
Prerequisites:
- The URL rewrite and the ARR modules need to be installed and enabled
https://www.iis.net/downloads/microsoft/url-rewrite
https://www.iis.net/downloads/microsoft/application-request-routing - Check the "Enable proxy" checkbox located in Application Request Routing feature view in IIS Manager.
- Open Internet Information Services (IIS) Manager.
- In the Connections pane, select the server.
- In the server pane, double-click Application Request Routing Cache.
- In the Actions pane, click Server Proxy Settings.
- On the Application Request Routing page, select Enable proxy.
Add the rules
Navigate to IIS manager > Select your server > Sites > Select your site > Open URL Rewrite.
In the "Server Variables" section, add your Prerender.io Token from the Security and Access menu to be forwarded to us:
- Click Add...
- Server variable name:
HTTP_X_PRERENDER_TOKEN
- Value:
[YOUR TOKEN]
- Check "Replace the existing value"
Click "Add rule(s)..." on the right-hand side and select "Blank rule".
Name the rule (e.g. Prerender.io rewrite rule)
Set up the "Match URL" section to look like this:
- Requested URL: Does Not Match the Pattern
- Using: Regular Expression
- 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)
- Check ignore case if your site URLs are case insensitive
Add two rules in the "Conditions" section:
- 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"
- Condition input:
- Rule 2:
- Condition input:
{QUERY_STRING}
- Check if input string: Matches the Pattern
- Pattern:
_escaped_fragment_
- Condition input:
- Set the "Logical grouping" to "Match Any".
- Rule 1:
Set up the "Action" section to match the following:
- Action type: Rewrite
- Rewrite URL:
https://service.prerender.io/https://{HTTP_HOST}{REQUEST_URI}
- Uncheck "Append query string"
- To get better logging, check "Log rewritten URL" (optional)
- Check "Stop processing of subsequent rules" (optional, this may also depend on your setup)
Notes:
- 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.
- Use Rewrite URL:
- 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.