Search code examples
url-rewritingumbracoumbraco7

url-rewriting omitting directory from url?


Is it possible to remove a directory from URL? for example for the below urls:

http://localhost:50656/umbraco/Surface/HealthInsurance/Application?Pid=26665&Lid=73&Spid=23

http://localhost:50656/umbraco/Surface/HealthInsurance/Results/73

there need to remove umbraco/Surface/ and make it

http://localhost:50656/HealthInsurance/Application?Pid=26665&Lid=73&Spid=23

    http://localhost:50656/HealthInsurance/Results/73

Please guide what will be regular expression for this.


Solution

  • In the web server section of your web config you can add the following. It will match the url .*, which is everything and will map it to /umbraco/Surface/{R:0}. The R:0 is the entire captured response. Make sure you have the module installed. Here is a tutorial on how to check if you have your rewrite set and you can test it. http://www.iis.net/learn/extensions/url-rewrite-module/testing-rewrite-rule-patterns

    <system.webServer>  
        <rewrite>
            <globalRules>
                <rule name="MapUmbarco">
                    <match url=".*" />
                    <action type="Rewrite" url="/umbraco/Surface/{R:0}" />
                </rule>
            </globalRules>
        </rewrite>
    
    </system.webServer>