Loading ...

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

301 redirect from http to https with web.config

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:

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

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)

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

Top Posts