How to configure a redirect using the IIS URL Rewrite module

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.

Using the IIS URL Rewrite module for more security

The URL rewrite module can also be used to reduce information disclosure in IIS:

Prerequisites

  • Ensure that you are using IIS 7 or above.
  • The IIS URL Rewrite module is installed during the SquaredUp DS 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 DS instance

Configuring a redirect to switch traffic from HTTP to HTTPS

How to redirect Open Access dashboards following a side-by-side upgrade to v5

Configuring a redirect to switch traffic from the root to a SquaredUp DS instance

You can redirect traffic that goes to the root URL to go directly to your SquaredUp DS instance to make the URL shorter and easier to use. For example, instead of having to use https://mywebsite.com/squaredup, your users would just have to enter https://mywebsite.com to reach SquaredUp DS.

  1. Open IIS Manager and click on Default Website
  2. In the main panel, double-click on URL Rewrite.
  3. Click Add Rule(s)... on the right-hand menu.
  4. With Blank rule selected click OK.
  5. Give the rule a name, such as 'Root Hit Redirect'.
  6. 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.
  7. In the Action section change the Action type from Rewrite to Redirect.

  8. Copy the following into the Redirect URL box:
    /squaredup


    where squaredup is the application name of your SquaredUp DS instance from your URL.

  9. 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.
  10. Ensure Append query string is ticked. This is will add either /SquaredUp to the URL and redirect the user to their dashboard.
  11. The Inbound Rule should look like this:
  12. Click Apply on the right-hand menu under Actions.

Configuring a redirect to switch traffic from HTTP to HTTPS

For more information about SSL/TLS and HTTPS see How to configure TLS/SSL (HTTPS)

To redirect all HTTP requests to HTTPS use the following steps:

  1. Open IIS Manager and click on the website that hosts the SquaredUp DS instance (on Azure this is usually SquaredUpv4 or SquaredUpv5).
  2. In the main panel, double-click on URL Rewrite.
  3. Click Add Rule(s)... on the right-hand menu.
  4. With Blank rule selected click OK.
  5. Give the rule a name, such as 'Redirect to HTTPS'.
  6. Copy the following and paste into the Pattern box in the Match URL section:
    (.*)
  7. Click to expand the Conditions section.
  8. Click Add… to add a new condition to the configuration.
  9. Copy the following and paste into the Condition input box :
    {HTTPS}


  10. Copy the following and paste into the the Pattern box:
    ^OFF$


  11. Click OK.
  12. Scroll down and in the Action section
  13. In the Action section change the Action type from Rewrite to Redirect.
  14. Copy the following and paste into the Redirect URL box:
    https://{HTTP_HOST}/{R:1}
  15. Change the Redirect type from Permanent (301) to See Other (303).
  16. Click Apply on the right-hand menu under Actions.

  17. Click Back to Rules.
  18. 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.

How to redirect Open Access dashboards following a side-by-side upgrade to v5

When you run SquaredUp DS v4 and v5 side-by-side, you can redirect your v4 Open Access links to the v5 Open Access dashboards. This way, users can get the benefits of Open Access on v5, such as the ability to hover over data to get more information.

This redirect only works as long as the v4 application pool is running and SquaredUp DS v4 is installed. If you remove SquaredUp DS v4 version, you need to use the new v5 links to access the dashboards.

When upgrading from SquaredUp DS v4 to v5 the Open Access dashboard IDs remain the same, which is why you can redirect the old v4 Open Access URLs to the new v5 Open Access URLs using the IIS URL Rewrite module .

Configuring a redirect to switch traffic from v4 to v5 Open Access dashboards

These instructions apply to the default installation configuration where SquaredUp DS is installed to an application underneath a website. If you have a different configuration please contact SquaredUp Support

  1. Open IIS Manager and click on the SquaredUpv4 application (you may have used a different name at installation).
  2. In the main panel, double-click on URL Rewrite.
  3. Click Add Rule(s)... on the right-hand menu.
  4. With Blank rule selected click OK.
  5. Give the rule a name, such as 'Open Access Redirect'.
  6. In the Match URL section copy the following regex into the Pattern box:
    (OpenAccess\/)([a-z0-9]{10}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12})
  7. The regex Pattern value matches the OpenAccess/[Open Access ID GUID] call that is made by the browser when first opening an Open Access dashboard.
  8. In the Action section change the Action type from Rewrite to Redirect.
  9. Copy the following into the Redirect URL box:
    /squaredup/openaccess/{R:2}  /squaredup/openaccess/{R:2}

    where squaredup is the application name of your instance.
  10. Change the Redirect type from Permanent (301) to Temporary (307). A Temporary redirect is preferred as it doesn't allow the HTTP Method to be changed as part of the redirect, and it is well supported by different browsers.
  11. The Inbound Rule should look like this: Pattern: (OpenAccess\/)([a-z0-9]{10}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}) Action Type: Redirect Redirect URL: /squaredup/openaccess/{R:2} Redirect type: Temporary (307)
  12. Click Apply on the right-hand menu under Actions.
  13. With the redirect rule now in place. To updates wallboards to show the v5 Open Access dashboards the page should be manually refreshed, or the wallboard rebooted if that is easier. Any old Open Access links that have been emailed or saved should redirect when they are clicked.

The redirect will no longer work when the v4 application pool is stopped, or SquaredUp DS v4 is removed.

Was this article helpful?


Have more questions or facing an issue?