Loading ...

301 redirect from http to https with web.config | CodeAsp.Net

301 redirect from http to https with web.config

 /5
0 (0votes)

If you want to apply 301 (Redirect permanent) for all http requests to https you need to add the following section in your system.webserver section of your web.config file:

      <rewrite>
          <rules>
              <rule name="HTTP to HTTPS redirect" stopProcessing="true">
                  <match url="(.*)" />
                  <conditions>
                      <add input="{HTTPS}" pattern="off" ignoreCase="true" />
                  </conditions>
                  <action type="Redirect" redirectType="Permanent" url="https://{HTTP_HOST}/{R:1}" />
              </rule>
          </rules>
      </rewrite>

After adding the above section in the web.config you can verify via Fiddler to check it makes 301 redirects from http to https.

Comments (1)

   
carlauclair
Thanks for the solution but how to proceed when some fields (in the same column) have uppercase text and others have lowercase text?  For the same length, column width will be not the same?  Exemple:FieldName CAROLINEChristinBoth are length=8 but do not need the same space in the column.  So we need to define a different parameter for the Substring method to get the text fitted in the column.Thanks.Carl
9/10/2010
 · 
by

Top Posts