The IIS development team is constantly working to expand the capabilities and improve the performance of the web server, but some of the recently published add-ons require special attention - the path rewriting module and the query routing module. So let's pay attention to them.
URL rewrite moduleThis is perhaps the main joy for web application developers using IIS. What modern Internet user would prefer an address like
habrahabr.ru/content?type=blog§ion=microsoft to a much more readable
habrahabr.ru/blog/microsoft ?
The absence of a module similar to Apache's
mod_rewrite made life difficult for developers working with IIS, although creating a
solution for rewriting paths in the form of an HttpModule is not a big deal. However, the new module, which is in the preview version (CTP) stage, is closely integrated with IIS and has great features:
')
- Creating path rewriting rules using regular expressions or character masks (*,?)
- Overwriting paths either at the server level or at a separate directory / application level
Rules for directories are defined in the web.config file, for the entire server in applicationHost.config. The rules are edited using a graphical interface embedded in the IIS7 management console. - Using information from server variables and HTTP request headers when creating rules
Thus, paths can be rewritten not only on the basis of the URL, but also on the basis of the request context, which allows the application to be managed flexibly — for example, to redirect users depending on the REMOTE_ADDR value — the IP address. - Perform actions other than URL rewriting
For example, instead of rewriting the URL, a redirect may be performed, the request may be canceled, or an arbitrary response code returned.
Good news for those who host PHP applications on IIS — The IIS development team, along with the path rewrite module, provides a utility for converting mod_rewrite rules into the format of rules that the module for IIS can understand.
More information about the module can be found on the official website of IIS (EN):
A good example of using the rewriting module for peaceful purposes can be found in the article on the
support of “beautiful” addresses for WordPress on IIS7 .
Download the preliminary version of the URL rewrite module:
x86 ,
x64 .
Request Routing ModuleAnother useful module for high-load web applications that allows you to redirect requests to different servers, depending on the current load, query parameters or the values ​​of environment variables. The module is based on the path rewriting module described above and introduces the following additional functionality:
- Load balancing
Six algorithms are supplied with the module for load balancing between servers. - Routing queries based on the values ​​of environment variables or query parameters
- Server health monitoring
Monitoring is carried out on the basis of work requests and specified addresses. - Binding users to servers based on cookies
- Diagnose routing problems and accumulate query statistics
To work with statistics, a graphical interface has been implemented in the IIS7 management console.
More information about the work of the module, you can read articles:
Download the preliminary version of the query routing module:
x86 ,
x64 .