1

In IIS7 there is a rule in place to redirect to HTTPS automatically that is used by our site.

<rule name="Redirect to HTTPS" enabled="true" stopProcessing="false">
    <match url="(.*)" />
    <conditions>
        <add input="{HTTPS}" pattern="^OFF$" />
    </conditions>
    <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="SeeOther" />
</rule>

We are adding a new domain (for example purposes www.newdomain.com) to our site that is using the same web application, but with the url being handled differently. When accessed at newdomain.com, or similarly, www.newdomain.com, the user should be redirected to https://www.newdomain.com/example, as we do not currently have an SSL certificate for newdomain.com. However our existing domain uses a separate subdomain than www that we do not need handled by IIS. To handle this redirection I use the following rule:

<rule name="Redirect newdomain" enabled="true" stopProcessing="false">
    <match url="(^$)" />
    <conditions>
        <add input="{HTTP_HOST}" pattern="^(www\.)?newdomain\.com$" />
    </conditions>
    <action type="Redirect" url="https://www.newdomain.com/example" appendQueryString="true" redirectType="Permanent" />
</rule>

This rule works when accessing the site from www.newdomain.com. However, when trying to access newdomain.com without the subdomain, the redirection only occurs for the initial rule, and the user is directed to https://newdomain.com, and a ssl certificate error. How can I get redirection to set the correct subdomain, while not effecting any sites only using the other rule?

Your Answer

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

Browse other questions tagged or ask your own question.