Add HTTPS redirect rewrite rule to web.config

jxharding's Avatar


13 Oct, 2017 07:50 AM

I've done variable replacement and Transforms via Octo on various occasions, but this is a bit different. It is inserting complete section to the existing

For development purposes in Visual Studio, we can't have an HTTP to HTTPS redirect, but we need it when the site is deployed. In other words this section does not exist during development.

I am asking assistance in how to add this section to the config please:

        <rule name="HTTP to HTTPS redirect" stopProcessing="true">
            <match url="(.*)"/>
            <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                <add input="{HTTPS}" pattern="off" ignoreCase="true"/>
            <action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Found"/>

The attached file shows an example of a demo web.config, and how that demo looks with the rewrite rule added.

I have seen multiple help pages on using powershell for redirect rules, but can't get to grips on how to add this specific rewrite rule.

Can this be done in powershell ? can it be done in Octo via transforms?

  1. Support Staff 1 Posted by Shane Gill on 16 Oct, 2017 12:10 AM

    Shane Gill's Avatar


    Thanks for getting in touch.

    I think your best bet is to use configuration transforms to add that section to your config. There is documentation here on configuration transforms, you want the "insert" transform:

    Create a transform file beside your config file and get Octopus to do the transformation when you deploy:

    Hope this helps.


  2. Paul Stovell closed this discussion on 25 Jan, 2018 05:08 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac