Home » IIS » URL Rewrite Inbound rule to strip out folder names from URLs

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>
URL Rewrite Inbound rule to strip out folder names from URLs
URL Rewrite Inbound rule to remove folder from path

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

Ned Sahin

Blogger for 20 years. Former Microsoft Engineer. Author of six books. I love creating helpful content and sharing with the world. Reach me out for any questions or feedback.
Categories IIS

Leave a Comment