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 have no idea why this isn't working. I've tried creating map rules and then rewritng and redirecting the url. I've tried just redirecting it with a simple rewrite rule and no matter what, the only time I can get it to work is if I set the match url to match this regex .*.

I'm trying to redirect webmail.example.com to mail.example.com. Seemed like it would have taken but a couple seconds; boy was I wrong. I'm thinking I must be doing something wrong with the regex, but I'm not sure what as when I test it it seems to work fine.

            <rule name="webmail" patternSyntax="ECMAScript" stopProcessing="true">
                <match url=".*webmail.*" />
                <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                </conditions>
                <action type="Redirect" url="https://mail.example.com:8000" appendQueryString="false" logRewrittenUrl="true" />
            </rule>

Thanks

share|improve this question
add comment

2 Answers

up vote 0 down vote accepted

The domain name is not part of the URL so you can't match against that. You have to add a condition to match against the HTTP_HOST variable. if you want any URL on that domain to be redirected, you have to match againt .*.

E.g. the following is probably what you want:

<rule name="webmail">
    <match url=".*" />
    <conditions>
        <add input="{HTTP_HOST}" type=”Pattern” pattern="^webmail\.example\.com$">
    </conditions>
    <action type="Redirect" url="https://mail.example.com:8000" />
</rule>
share|improve this answer
    
in case I need to remember this again later, also make sure you have webmail.domain.com added into the site binding. –  Jason White Dec 8 '12 at 11:04
add comment

Why not create two IIS sites with host headers. For webmail.example.com one you use the IIS Manager -> HTTP Redirect to do it?

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.