What's New In 2.1.0 - URL Rewrite Administration
Via Microsoft IIS Administration API 2.1.0
If you are unfamiliar with the API, check out our earlier post for an introduction.
The IIS team has been working on making the IIS Administration API a complete solution for managing all aspects of the web server. The newest addition to the API is an endpoint for the URL Rewrite module. This module is one of the most popular due to its ability to provide complete control over HTTP requests and responses at the webserver level. With the new API endpoint , obtaining, configuring, and using the URL Rewrite module is easier than ever.
Install And Uninstall Via the API
Unlike most IIS modules, URL Rewrite does not come by default with Windows. This meant that to start using the module one needed to download it and then install it on the web server. With the new URL Rewrite endpoint, the module can be installed with a single request just like any other IIS feature. The API will obtain the latest version of URL Rewrite, install it on the web server, and then report the success of the installation. Uninstalling URL Rewrite is also supported, so performing an upgrade from an older version is possible by uninstalling and then reinstalling via this new endpoint.
Complete Coverage
URL Rewrite is capable of satisfying many scenarios in a simple manner, but it is also possible to use URL Rewrite for advanced scenarios such as implementing CORS. To handle all this functionality URL Rewrite comes with a lot of switches and knobs. This new endpoint exposes all of the configuration for URL Rewrite through JSON resources.
One common scenario encountered in web development is the desire to redirect all HTTP traffic to HTTPS for a given website. Below is a URL Rewrite rule that can be used for this purpose as seen through the IIS Administration API.
{
"name": "Redirect to HTTPS ",
"id": "{id}",
"priority": "0",
"pattern": "(.*) ",
"pattern_syntax": "regular_expression ",
"ignore_case": "true ",
"negate": "false ",
"stop_processing": "true ",
"response_cache_directive": "auto ",
"condition_match_constraints": "match_any ",
"track_all_captures": "false ",
"action": {
"type": "redirect ",
"url": "https://{HTTP_HOST}/{R:1} ",
"append_query_string": "true ",
"log_rewritten_url": "false ",
"redirect_type": "found "
},
"server_variables": [],
"conditions": [
{
"input": "{HTTPS} ",
"pattern": "off ",
"negate": "false ",
"ignore_case": "true ",
"match_type": "pattern "
}
],
"url_rewrite": {
"id": "{rewrite-id}",
"scope": "Default Web Site/ ",
"_links ": {
"self": {
"href": "/api/webserver/url-rewrite/{rewrite-id}"
}
}
}
}
URL Rewrite Web UI
To compliment the new endpoint, a URL Rewrite section has been added to https://manage.iis.net. This UI enables users to install and customize URL Rewrite for the web server. There are multiple features to aid in customizing URL Rewrite rules including regex testing, auto fill suggestions for IIS server variables, and rule cloning.
For the initial release of the URL Rewrite UI on https://manage.iis.net there will not be support for preconditions and custom tag sets on outbound rewrite rules. These features will be added into the UI at a later date, however they are already present in Microsoft IIS Administration API 2.1.0.
Feedback
The IIS team would love to hear what users think of the experience we're building at https://manage.iis.net, so we've added a feedback button. The new button can be found at the top right of the web manager and in the settings menu on mobile devices.