What is the IIS Rewrite Module?
The IIS 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 rewrite module and its features can be found here.
See the following on how to create a redirect rule to switch traffic to a custom SquaredUp instance.
Configure the Redirect
- Ensure that you are using IIS 7 or above.
- Download and install the IIS rewrite module version 2.0, the latest download link for this can be found here.
- Close and re-open IIS to ensure that the URL Rewrite module loads.
- On the left hand panel click on Default Website and then double click on URL Rewrite from the main panel.
- Under Actions in the right panel select Add Rule(s)...
- With Blank rule selected click OK.
- Create a meaningful name for your rule, e.g
Root Hit Redirect
-
In the pattern section enter the regular expression
^$
as shown below, this asserts position at the start and end of the string entered.Requested URL: Matches the Pattern
Using: Regular Expressions
Pattern:
^$
-
In the Action section add the following:
Action Type: Redirect
Redirect URL: Type either
/SquaredUpv4
or/SquaredUpv5
(depending on the version you are running)Redirect Type: 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. - On the right-hand side under Actions click Apply.
HTTP to HTTPS
To set a redirect to redirect all HTTP to HTTPS requests use the following steps:
- Open IIS.
- On the left hand panel click on Default Website and then double click on URL Rewrite from the main panel.
- Under Actions in the right panel select Add Rule(s)....
- With Blank rule selected click OK.
- Enter
Redirect to HTTPS
in the name field. -
Within the Match URL configuration box we will set the following settings:
Requested URL: Matches the Pattern
Using: Regular Expressions
Pattern:
(.*)
- Select Conditions and press Add… to add a new condition to the configuration.
-
Add the following condition:
Condition Input:
{HTTPS}
Check if input string: Matches the Pattern
Pattern:
^OFF$
-
In the Action section add the following:
Action Type: Redirect
Redirect URL:
https://{HTTP_HOST}/{R:1}
Redirect Type: See Other (303)
- On the right-hand side under Actions click Apply, then click Back to Rules.
If you have BOTH of these rules set up ensure that you move your HTTP redirect, to be listed above your SquaredUp re-direct as shown in the image below.