We have two sites in IIS7 both on port 80. One is our actual website (MAIN) the other is a maintenance site (MAINTENANCE) that we start (and stop the other one) when we are deploying a new version of MAIN.

When we put MAINTENANCE live, if you browse to one of our subfolders (i.e. http://maintenance/product1) you'll get a 404. I want to use the URL Rewrite module to redirect to the root of the site (http://maintenance/).

I can get this working in a basic manner, but the image and css are not working. In other attempts I have ended up with a continual redirect.

Is this possible?


For anyone who arrives here via Google, I managed to get it to work with the following rule:

        <clear />
        <rule name="Force HTTP" stopProcessing="true">
            <match url="(.*)" />
            <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                <add input="{HTTPS}" pattern="on" />
            <action type="Redirect" url="/{R:1}" redirectType="Temporary" />
        <rule name="Allow Local Resources" stopProcessing="true">
            <match url=".*" />
            <conditions logicalGrouping="MatchAny" trackAllCaptures="false">
                <add input="{REQUEST_FILENAME}" pattern="SiteMaintenance.png" />
                <add input="{REQUEST_FILENAME}" pattern="Stylesheet.css" />
            <action type="None" />
        <rule name="Check Is Root" stopProcessing="true">
            <match url="^.+$" negate="false" />
            <conditions logicalGrouping="MatchAny" trackAllCaptures="false" />
            <action type="Redirect" url="/" appendQueryString="false" redirectType="Temporary" />

No idea if this is the best way, but it worked for me.


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.