Welcome to the navigation

Tempor duis cupidatat commodo sed magna irure elit, anim ut deserunt labore ad est ullamco qui pariatur, sunt aliquip aute consectetur lorem quis in esse. Ut minim id mollit commodo ullamco exercitation sed in velit duis occaecat amet, voluptate et veniam, nulla labore ad officia cillum est cupidatat laboris excepteur

Yeah, this will be replaced... But please enjoy the search!

Redirecting HTTP to HTTPS using IIS Url Rewriting

Categories Tags

I've always been a bit puzzled over the magic that surrounds Url Rewriting, it is actually very simple. What you need to do is

  1. Name the rule
  2. Create a pattern to use for matching the URL string that shall be rewritten
  3. Optional set of conditions
  4. Select the wanted action to perform if a pattern is matched and whether all conditions checks succeed

Name, Pattern, Conditions, Action.

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
   <system.webServer>
      <rewrite>
         <rules>
            <rule name="Redirect HTTP to HTTPS" stopProcessing="true">
               <match url="(.*)" />
               <conditions>
                  <add input="{HTTPS}" pattern="off" />
               </conditions>
               <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Permanent" />
            </rule>
         </rules>
      </rewrite>
   </system.webServer>
</configuration>

Since this is a snipped post I won't get into much depth but I'd like to remark the redirectType attribute in the action element in the example since that will affect search engines and some clients a lot. In my sample this is set to "Permanent", this equals a 301 redirect. There are a few other options available

  • Permanent (301)
  • Found (302)
  • See other (303)
  • Temporary (307)

Read more at, http://www.iis.net/learn/extensions/url-rewrite-module/url-rewrite-module-configuration-reference#Redirect_action

Please note that this portal is a BETA site , I will continuously improve all functionality and performance during the coming weeks / the author