Remove directory from URL IIS 7.5

Posted by xalx on Server Fault See other posts from Server Fault or by xalx
Published on 2012-10-05T22:07:15Z Indexed on 2012/10/06 9:39 UTC
Read the original article Hit count: 220

Filed under:
|
|

I've tried to find a solution to this and found some guides out there but none seem to work.

I have the following URL - http://www.mysite.com/aboutus.html

However there are some other sites which link to my old hosted site and point to http://www.mysite.com/nw/aboutus.html. My issue here is trying to remove the 'nw' directory from the URL's.

I have setup the following URL Rewrite in IIS but it does not seem to do anything,

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>   
                <rule name="Redirect all to root folder" enabled="true" stopProcessing="true">
                    <match url="^nw$|^/nw/(.*)$" />
                    <conditions>
                    </conditions>
                    <action type="Redirect" url="nw/{R:1}" />
                </rule>
                <rule name="RewriteToFile">
                    <match url="^(?!nw/)(.*)" />
                    <conditions>
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="/{R:1}" />
                </rule>
            </rules>
        </rewrite>

    </system.webServer>
</configuration>

Any insight would be appreciated.

© Server Fault or respective owner

Related posts about iis

Related posts about rewrite