Using the rewrite module to redirect part of a website
Example of configuring the rewrite module in the web.config file.
How to create a Web.config URL Rewrite Rule
Create a rule to match the URL pattern you want to retain. Include all files such as css, js, images, etc. that also need to be retained, and stop further processing if this rule is matched.
Then create another rule pattern that matches the URL you want to retain, but negate that rule to send all other URL patterns to the redirected website.
<rewrite>
<rules>
<clear />
<rule name="Rule_1" stopProcessing="true">
<match url="(.*)"/>
<conditions logicalGrouping="MatchAny">
<add input="{REQUEST_URI}" pattern="PageToKeep" ignoreCase="true"/>
<add input="{REQUEST_URI}" pattern=".css" ignoreCase="true"/>
<add input="{REQUEST_URI}" pattern=".js" ignoreCase="true"/>
<add input="{REQUEST_URI}" pattern="bundles" ignoreCase="true"/>
<add input="{REQUEST_URI}" pattern="bootstrap" ignoreCase="true"/>
<add input="{REQUEST_URI}" pattern="kendo" ignoreCase="true"/>
<add input="{REQUEST_URI}" pattern=".gif" ignoreCase="true"/>
<add input="{REQUEST_URI}" pattern=".png" ignoreCase="true"/>
<add input="{REQUEST_URI}" pattern=".ico" ignoreCase="true"/>
<add input="{REQUEST_URI}" pattern=".woff" ignoreCase="true"/>
<add input="{REQUEST_URI}" pattern=".ttf" ignoreCase="true"/>
</conditions>
</rule>
<rule name="Rule_2" stopProcessing="true">
<match url="PageToKeep" negate="true" ignoreCase="true"/>
<action type="Redirect" url="https://NewWebsite.com" redirectType="Found" appendQueryString="false" />
</rule>
</rules>
</rewrite>
For further information, see the following:
URL Rewrite Module Configuration Reference