Install and set up URL Rewrite

If you are operating on a WorkZone installation that contains HTTP references after having converted the installation to run in an HTTPS environment, you can install and configure the URL Rewrite extension to the Microsoft Internet Information Server (IIS).

The URL Rewrite extension enables you to replace the HTTP protocol part of a URL with its HTTPS equivalents – for example changing SmartTask references in WorkZone Client still containing HTTP to their HTTPS equivalents without having to locate and update all links and references.

The URL Rewrite detects the URL request containing the HTTP request and rewrites the URL, replacing the HTTP protocol part of the URL with HTTPS before it is processed by the WorkZone server.

This is a bit different than a URL redirect operation as a URL redirect operation sends information back to the client requesting an incorrect URL (or at least the URL which is to be redirected). The information enables the client to then request the correct URL and display the results. A redirect is a client-side request that redirects the web browser to access another predefined URL.

A URL rewrite is processed on the server and “rewrites” or updates the requested URL to another predefined URL. The requesting client does not receive any information regarding the new URL from the server. The only indication that the new URL is used is the new URL displayed in the address bar. A URL rewrite is a server-side edit of a URL before it is processed by the IIS.

Disable URL rewriting of requests generated through the WZ Client, Internet Proxy, the firewall and the Net Load Balancer.

Clear the cache of the client machine’s web browser to remove any URL Rewrite rules from the cache.


Download and Install the URL Rewrite extension

The URL Rewrite extension is not installed by default on IIS servers and must be downloaded and installed separately.

Download and run the rewrite_amd64_en-US.msi installer from the Microsoft homepage to install the URL Rewrite extension.

To check if the URL Rewrite extension has been correctly installed, open the Internet Information Services (IIS) Manager form for the WorkZone site. The URL Rewrite extension is displayed in the IIS section on the information (right) pane for the WorkZone site.

If the Internet Information Services (IIS) Manager form was open during the installation, the URL Rewrite extension may not be displayed as the form needs to be updated.

Close and reload the form to display the URL Rewrite extension for the WorkZone site. In some cases, you may have to reboot the IIS server for the changes to take effect.


Set up URL Rewrite

After the URL Rewrite extension is installed, you must clear the Require SSL check box to accept HTTP calls for the WorkZone site.

In the Internet Information Services (IIS) Manager form, WorkZone site, click SSL Settings in the IIS section on the information (right) pane for the WorkZone site and clear the Require SSL check box.

If the Require SSL check box is selected, any URL requests containing HTTP will be rejected before the URL Rewrite extension can access the HTTP request to rewrite the request.

Create, edit, enable and disable URL Rewrite rules

Once you have correctly set up the URL Rewrite settings, you can create new URL rewrite rules.

Remember to create a backup copy of the web.config file before creating new URL rewrite rules through the IIS Manager.

In the Internet Information Services (IIS) Manager form, WorkZone site, double-click URL Rewrite in the IIS section on the information (right) pane for the WorkZone site to open the URL Rewrite panel.

In the URL Rewrite pane, you can add new URL rewrite rules, edit existing rules, enable and disable rules as well as test the URL rewrite rules.

Each rule must be created manually. You cannot import or export rules in the URL Rewrite pane.

The IIS settings are stored in the web.config file for the selected site. If you need to mass-create or mass-update URL rewrite rules, you can edit the web.config file instead, copy-pasting the relevant lines to and from web.config files.

All URL rewrite rules in the web-config file are displayed in the URL Rewrite panel.

Use the Web.config file to create URL rewrite rules

You can use the web.config file on the IIS server to manually create and edit URL rewrite rules. The web.config file is an XML-based configuration file used by IIS to manage various settings used to configure a website hosted on IIS. The web.config file can be edited in any text-editor and in this way you can control a website’s configuration without editing the server’s configuration.

The default path to the web.config file is C:\Program Files (x86)\KMD\WorkZone\IIS\WorkZone.

Remember to create a backup copy of the web.config file before manually editing the file.

To create URL rewrite rules in a web-config file, you must add the following rules:

<rule name="httpsRedirect" enabled="true" stopProcessing="true">

<match url="(.*)" />

<conditions>

<add input="{HTTPS}" pattern="^OFF$" />

</conditions>

<action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" appendQueryString="false" redirectType="Temporary" />

</rule>

<rule name="assetRootRedirect" enabled="true" stopProcessing="true">

<match url="(.*)" />

<conditions trackAllCaptures="true">

<add input="{HTTPS}" pattern="^ON$" />

<add input="{QUERY_STRING}" pattern="^(.*)assetRoot=http://(.*)$" />

<add input="{QUERY_STRING}" pattern="^.*assetRoot=https://.*$" negate="true" />

</conditions>

<action type="Redirect" url="https://{HTTP_HOST}{URL}?{C:1}assetRoot=https://{C:2}" appendQueryString="false" redirectType="Temporary" />

</rule>

The httpsRedirect rule rewrites the first part of the URL to HTTPS while the assetRootRedirect rewrites the internal HTTP URL. For example for WorkZone SmartMail which employs an imbedded URL in the URL.

See Also

URL Rewrite (External link to IIS.net)