What is the IIS URL Rewrite module?
The IIS URL Rewrite module is a tool used to convert complex web addresses into consistent, memorable, URL's. The rewrite module produces URLs which are simple for users to remember and for search engines to find.
The rewrite module is based on HTTP headers and IIS server variables. It performs redirects, sends custom responses, or stops HTTP requests based on the logic expressed in the rewrite rules. Access to web site content is controlled by URL segments or metadata.
More information on the IIS URL Rewrite module and its features can be found here.
Prerequisites
- Ensure that you are using IIS 7 or above.
- The IIS URL Rewrite module is installed during the SquaredUp setup, if it not already installed. Alternatively, you can download IIS URL Rewrite module version 2 from Microsoft here. Close and re-open IIS to ensure that the IIS URL Rewrite module loads.
Instructions for Configuring useful redirects
Configuring a redirect to switch traffic from the root to a SquaredUp instance
Configuring a redirect to switch traffic from HTTP to HTTPS
Configuring a redirect to switch traffic from v4 to v5 Open Access dashboards
Configuring a redirect to switch traffic from the root to a SquaredUp instance
- Open IIS Manager and click on Default Website
- In the main panel, double-click on URL Rewrite.
- Click Add Rule(s)... on the right-hand menu.
- With Blank rule selected click OK.
- Give the rule a name, such as 'Root Hit Redirect'.
-
In the Match URL section copy the following regex into the Pattern box:
^$
this asserts position at the start and end of the string entered. - In the Action section change the Action type from Rewrite to Redirect.
-
Copy the following into the Redirect URL box:
/squaredupv5
wheresquaredupv5
is the application name of your SquaredUp instance. If you are running SquaredUp v4 this should be/SquaredUpv4
- Change the Redirect type from Permanent (301) to Found (302). We recommend the use of a 302 temporary redirect. Do NOT use 301 which is a permanent redirect and difficult to change at a later date.
- Ensure Append query string is ticked. This is will add either
/SquaredUpv4
or/SquaredUpv5
to the URL and redirect the user to their dashboard. - The Inbound Rule should look like this:
- Click Apply on the right-hand menu under Actions.
Configuring a redirect to switch traffic from HTTP to HTTPS
To set a redirect to redirect all HTTP to HTTPS requests use the following steps:
- Open IIS Manager and click on Default Website
- In the main panel, double-click on URL Rewrite.
- Click Add Rule(s)... on the right-hand menu.
- With Blank rule selected click OK.
- Give the rule a name, such as 'Redirect to HTTPS'.
- In the Match URL section copy the following regex into the Pattern box:
(.*)
- Click to expand the Conditions section.
- Click Add… to add a new condition to the configuration.
- In the Condition input box paste the following:
{HTTPS}
- In the Pattern box paste:
^OFF$
- Click OK.
- Scroll down and in the Action section
-
In the Action section change the Action type from Rewrite to Redirect.
-
Copy the following into the Redirect URL box:
https://{HTTP_HOST}/{R:1}
- Change the Redirect type from Permanent (301) to See Other (303).
- Click Apply on the right-hand menu under Actions.
- Click Back to Rules.
- If you have other redirects configured you should ensure that you move your Redirect to HTTPS redirect to be listed first as shown in the image below. You can do this using the Move Up and Move Down options on the right.