Site icon port135.com

URL Rewrite Inbound rule to strip out folder names from URLs

Let’s say your website’s address is this:

http://testsite.com/testapp/default.htm

but you want your users to see the URL below in their address bar (The name “testapp” is removed)

http://testsite.com/default.htm

Here is the URL Rewrite Inbound rule to use for striping out the folder name from the path:

<rewrite>
      <rules>
           <rule name="Remove testapp" stopProcessing="true">
                <match url=".*(testapp)(.+)" />
                <action type="Redirect" url=http://testsite.com{R:2} appendQueryString="false" />
           </rule>
      </rules>
</rewrite>

If you also want to redirect HTTP to HTTPS, check this post out: How to redirect HTTP requests to HTTPS by using IIS URL Rewrite

If you receive an error related to this configuration, this post may help: The configuration section rewrite/globalRules cannot be read because it is missing a section declaration

Exit mobile version