Redirect random and the middle virtual directoryRSS

3 replies

Last post Aug 26, 2020 12:29 PM by Aucesar

  • Redirect random and the middle virtual directory

    Aug 22, 2020 06:27 PM|Aucesar|LINK

    Hi IIS Community,

    I´m testing Myrtille (RDP Web client - Github) and it generates url´s like this one when accessed

    https://myserver.com/(S(5rgrnygt5kkacaxl3gumnpq4))/default.aspx

    I need a rule to rewrite this way:

    https://connection.mycompanysite.com to https://myserver.com/(S(5rgrnygt5kkacaxl3gumnpq4))/default.aspx

    My problem to create this rule is the "random in the middle" virtual directory the application creates as a session control.

    I also desire to hide everything after / keeping the browser url showing only https://connection.mycompanysite.com , if possible.

    Both servers are different and the companysite.com server is a hosting provider without access to the IIS just web.config and the second one I have full access to the IIS.

  • Re: Redirect random and the middle virtual directory

    Aug 24, 2020 06:48 AM|Jalpa Panchal|LINK

    Hi,

    If you want to hide the subfolder name from the URL you could use rule like below:

    <rewrite>
                <rules>  
                    <rule name="Removefoldername" stopProcessing="true">
                        <match url="^foldername$|^foldername/(.*)$" />
                        <conditions>
                        </conditions>
                        <action type="Redirect" url="foldername/{R:1}" />
                    </rule>
                    <rule name="RewriteToFile">
                        <match url="^(?!foldername/)(.*)" />
                        <conditions>
                            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                        </conditions>
                        <action type="Rewrite" url="{R:1}" />
                    </rule>
                </rules>
            </rewrite>

    Aucesar

    https://connection.mycompanysite.com to https://myserver.com/(S(5rgrnygt5kkacaxl3gumnpq4))/default.aspx

    and for this set the rule at  companysite.com server web.config file:

     <rule name="rewrite test" stopProcessing="true">
                        <match url="^$" />
                        <conditions>
                            <add input="{HTTPS}" pattern="on" />
                            <add input="{HTTP_HOST}" pattern="connection.mycompanysite.com" />
                        </conditions>
                        <action type="Rewrite" url="https://myserver.com/(S(5rgrnygt5kkacaxl3gumnpq4))/default.aspx" logRewrittenUrl="true" />
                    </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: Redirect random and the middle virtual directory

    Aug 26, 2020 12:18 PM|Aucesar|LINK

    Thanks, this will guide me to solve the problem. If not I come back here!

  • Re: Redirect random and the middle virtual directory

    Aug 26, 2020 12:29 PM|Aucesar|LINK

    Jalpa Panchal

    <rule name="rewrite test" stopProcessing="true">
                        <match url="^$" />
                        <conditions>
                            <add input="{HTTPS}" pattern="on" />
                            <add input="{HTTP_HOST}" pattern="connection.mycompanysite.com" />
                        </conditions>
                        <action type="Rewrite" url="https://myserver.com/(S(5rgrnygt5kkacaxl3gumnpq4))/default.aspx" logRewrittenUrl="true" />
                    </rule>

    Hi Guess a missed some information this part (S(5rgrnygt5kkacaxl3gumnpq4)) is a random generate session control so I can´t put it fixed, I know I need to use a regex , which one I have no idea...Sorry....  During my tests using another reverse proxy solutions I always come with a symptom getting https://connection.mysite.com/(S(somethin)/default.aspx/default.aspx/default.aspx so the application keeps sending me /default.aspx every new attemp to load/connect.

    Again thanks for the help I´m trying to get a smooth solution for an application I can´t change so much code to do it better.

    Thx.