I'm running some websites on a IIS 7.5 with one UCC SSL certificate, where 10 domains are secured. most of them are something.company.ch, some are something.anothercompany.ch

we have a redirect rule in our web.config which redirects every HTTP request to a HTTPS request

my problem is, that we have domains like company.de, company.com which are not secured by the SSL certificate, but those domains actually point to my company.ch site (site binding in IIS).

if someone now opens the URL www.company.de he's getting a certificate error.

For best google rankings you should do the HTTPS redirect in web.config so we figured we need to do it like this. So we we're trying to redirect http://www.company.de first to http://company.ch and then to https://www.company.ch but unfortunately, this doesn't solve the issue.

Does anyone know how to solve this problem? Or a better way to get this done?

This is the web.config rule part

# Redirect of company.de to company.ch
<rule name="company.de to company.ch" patternSyntax="ECMAScript" stopProcessing="true">
    <match url=".*" />
    <conditions logicalGrouping="MatchAny">
        <add input="{HTTP_HOST}" pattern="^company.de$" />
    <action type="Redirect" url="https://www.company.ch/{R:0}" />

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

Two things:

  1. The redirect on the top still has https instead of http.
  2. The HTTP_HOST condition will strictly match company.de and not hosts like www.company.de. While I may get my regex wrong (typing on the phone leads to typos), the regex should be something similar to ^(.*\.)?something.de$
  • thank you for this answer. what do you mean by 1.) ? i don't see a mistake there. regex works good, thx for that – SimonS Mar 21 '16 at 14:15
  • Based on the question and if I understood correctly, company.de should first redirect to https //company.ch (not https) and then to http //company.ch. In the first redirect rule, which seems to be intended to do the first part, the action url still has https on the URL, which means company.de will redirect straight to https //company.ch and not http //company.ch (not https). Please note that I left out the colon on purpose. – milope Mar 21 '16 at 14:54
  • thank you, this answer helped me very much because of regex. the redirect works now! – SimonS Mar 23 '16 at 13:09

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.