0

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?

1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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