IIS redirect from page.nl to page.nl/other

32 views Asked by At

I am trying to figure out how to send the user of a website from https://my.site.nl to https:/my.site.nl/site

Our setup is like this:

root folder
    site folder
    webservice folder

The root folder has a web.config file with this in it:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <httpProtocol>
        </httpProtocol>
        <rewrite>
            <outboundRules>
                <rule name="Add Strict-Transport-Security when HTTPS" enabled="true">
                    <match serverVariable="RESPONSE_Strict_Transport_Security" pattern=".*"/>
                    <conditions>
                        <add input="{HTTPS}" pattern="on" ignoreCase="true"/>
                    </conditions>
                    <action type="Rewrite" value="max-age=31536000; includeSubDomains; preload"/>
                </rule>
                <rule name="RESPONSE_SERVER_REMOVE">
                    <match serverVariable="RESPONSE_SERVER" pattern=".*"/>
                    <action type="Rewrite" value=""/>
                </rule>
            </outboundRules>
            <rules>
                <rule name="HTTPS Redirect" stopProcessing="true">
                    <match url="(.*)"/>
                    <conditions>
                        <add input="{HTTPS}" pattern="^OFF$"/>
                    </conditions>
                    <action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" appendQueryString="true"/>
                </rule>
            </rules>
        </rewrite>
        <defaultDocument>
            <files>
                <clear/>
                <add value="default.aspx"/>
                <add value="Default.htm"/>
                <add value="Default.asp"/>
                <add value="index.htm"/>
                <add value="index.html"/>
                <add value="iisstart.htm"/>
            </files>
        </defaultDocument>
    </system.webServer>
</configuration>

So basically I want to redirect the user to the site folder in the root folder.

I have tried this:

<httpRedirect enabled="true" destination="https://my.site.nl/site/" httpResponseStatus="Permanent" childOnly="true" />

But that didn't do anything.

How can I do this?

1

There are 1 answers

2
samwu On

You can try this rule:

<rules>
  <rule name="redirect" stopProcessing="true">
     <match url="^(.*)$" />
        <conditions>
            <add input="{HTTP_HOST}" pattern="^my.site.nl$" />
        </conditions>
     <action type="Redirect" url="https://my.site.nl/site" appendQueryString="true" />
  </rule>
</rules>