ShareThis

IIS URL Rewrite Module - Redirect HTTP to HTTPS with IIS 7

Using IIS URL Rewrite Module, Web administrators can easily set up rules to define URL rewriting behavior based on HTTP headers, HTTP response or request headers, IIS server variables, and programmatic rules. Here the main purpose is to implement URLs that are easier for users to remember and easier for search engines to find.

In addition, we can define rules to force SSL on selected pages of a Website which is hosted in IIS 7. First of all we need to install Microsoft URL Rewrite Module in IIs. Then we need to install SSL certificate, create HTTPS bindings to our IIS Web site and assign the certificate. Then select our Web site under Sites node and make sure "Require SSL" is NOT checked under SSL Settings.

After that we have to add following config section to the web.config file in the Web site root directory.
















In here a rewrite rule is defined by specifying a pattern to use for matching the URL string and an action to perform if a pattern is matched. In addition an optional condition is also specified which will be checked in the matching step.

Thanks Carlos Redondo for your suggestion!

0 comments: