How to hide subfolder when using Web.config for subdomains?

Posted by mc-kay on Server Fault See other posts from Server Fault or by mc-kay
Published on 2011-02-14T16:37:21Z Indexed on 2012/05/30 22:42 UTC
Read the original article Hit count: 341

I have FTP access to my ASP.NET Websapce (IIS 7) and I route subdomains with a Web.config in the web root folder. She looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="route www and emtpy requests" stopProcessing="true">
                    <match url=".*" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                        <add input="{HTTP_HOST}" pattern="^(www.)?example.com" />
                        <add input="{PATH_INFO}" pattern="^/www/" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="\www\{R:0}" />
                </rule>
                <rule name="route to blog" stopProcessing="true">
                    <match url=".*" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                        <add input="{HTTP_HOST}" pattern="^blog.example.com$" />
                        <add input="{PATH_INFO}" pattern="^/blog/" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="\blog\{R:0}" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

As you can see i have two folders in my root directory: "www" and "blog". When i now enter "blog.example.com" everythink is working fine, but when i click a link i will go to "blog.example.com/blog"

What can I do to prevent this behavior ?

© Server Fault or respective owner

Related posts about iis7

Related posts about ASP.NET