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.

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?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

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

<rewrite>
<rules>
        <clear />
        <rule name="Force HTTP" stopProcessing="true">
            <match url="(.*)" />
            <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                <add input="{HTTPS}" pattern="on" />
            </conditions>
            <action type="Redirect" url="/{R:1}" redirectType="Temporary" />
        </rule>
        <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" />
            </conditions>
            <action type="None" />
        </rule>
        <rule name="Check Is Root" stopProcessing="true">
            <match url="^.+$" negate="false" />
            <conditions logicalGrouping="MatchAny" trackAllCaptures="false" />
            <action type="Redirect" url="/" appendQueryString="false" redirectType="Temporary" />
        </rule>
</rules>
</rewrite>

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

:)

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.