replace Protoco and HTTP_host for given pattern [Answered]RSS

2 replies

Last post Nov 05, 2019 07:38 AM by Jalpa Panchal

  • replace Protoco and HTTP_host for given pattern

    Nov 01, 2019 07:22 PM|scogordo|LINK

    Should be a simple one.

    I have a URL to a page. The folder/page name is /hr/documents.aspx. 

    The condition is that if this pattern matches with a given request, I want to switch the Protocol and HTTP_HOST to new values.

    Old URL New URL Notes
    http://my.intranet.contoso.local/hr/documents.aspx  https://myintranet.contoso.local/hr/documents.aspx  New URL adds https, combines subdomains

    If the URL is to another folder page, I want the Old URL to stay in place, eg: 

    http://my.intranet.contoso.local/hr/baseball.aspx 

    should not be changed in any way.

    Thanks!

  • Re: replace Protoco and HTTP_host for given pattern

    Nov 04, 2019 05:27 AM|Jalpa Panchal|LINK

    Hi,

    You could use below url rewrite rule:

     <rule name="rule1" enabled="true" stopProcessing="true">
                        <match url="(.*)" />
                        <conditions>
                            <add input="{HTTP_HOST}" pattern="^my.intranet.contoso.local$" />
                            <add input="{REQUEST_URI}" pattern="^/hr/documents\.aspx|/hr/documents" />
                        </conditions>
                        <action type="Redirect" url="https://myintranet.contoso.local/hr/documents.aspx" />
                    </rule>

    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue.
    If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
  • Re: replace Protoco and HTTP_host for given pattern

    Nov 05, 2019 07:38 AM|Jalpa Panchal|LINK

    we couldn't modify the HTTP host directly. by using this rule, it will just redirect the URL. 

    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue.
    If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.