Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm trying to simulate hosting multiple domains on a single website with IIS7.

I setup a folder structure that has a web_root folder which contains a simple index.html, a web.config, and a folder (connect) holding an asp.net web application. I have attempted to add a url rewrite rule that would take a request to the host localhost.nerdfurio.us and point it into the connect folder (I added localhost.nerdfurio.us to my hosts file as well).

The web.config in web_root looks like this

<configuration>
    <system.webServer>
        <modules runAllManagedModulesForAllRequests="true">
        </modules>
        <rewrite>
            <rules>
                <rule name="nerdfurious" stopProcessing="true">
                    <match url=".*" />
                    <conditions>
                        <add input="{HTTP_HOST}" pattern="^localhost.nerdfurio.us$" />
                        <add input="{PATH_INFO}" pattern="^/connect/" />
                    </conditions>
                    <action type="Rewrite" url="connect/{R:0}" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

When I type 'localhost.nerdfurio.us' into my browser, I get the contents of the index.html file. If I type localhost.nerdfurio.us/connect into my browser, I get a 404 error listing 'http://localhost.nerdfurio.us:80/connect/connect/' as the requested url. What am I missing?

share|improve this question
add comment

1 Answer

The problem was, the {PATH_INFO} rule needed to have a negate="true" attribute in the tag. This means when the pattern does not match. Since when I visited the root, "/connect/" was not in the url, and so all conditions were not met to do the rewrite action.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.