0

We have our own domain and have several subdomains. One of the sites needs to be accessed only via SSL, but people are allowed to type http and still arrive there. The URL-Rewrite forces the http into https.

So my two subdomains are: sub1.domain.org and sub2.domain.org.

Thus, if I type

http://sub1.domain.org/page_on_domain1

it is rewritten to

https://sub1.domain.org/page_on_domain1

-which is correct. But if I do this (which is not possible - page_on_domain1 does not exist on sub2.domain.org:

https://sub2.domain.org/page_on_domain1

My url-rewrite rule seems to work properly, but I want that last address to give me an error page instead, since the page doesn't exist on that subdomain.

I am testing this in Firefox on Windows 7 x64 Pro.

My url-rewrite rule is as follows (I am doing it through the IIS7 GUI):

Requested URL:  Matches the Pattern:  (*)  Using Regular Expressions (ignore case)
Conditions:  Match All:  Input:  {HTTPS}  Matches the Pattern:  ^Off$
Redirect URL:  https://sub1.domain.org/{REQUEST_URI}

Now, I've tried changing the Requested URL Pattern to: .*sub1.domain.org/.* but the regex tester in IIS7 says it doesn't match against https://sub1.domain.org - I don't understand that.

How can I keep the rewrite of http to https for sub1.domain.org, but not have any effect at all on sub2.domain.org ??

bgmCoder
  • 706
  • 4
  • 16
  • 29

1 Answers1

0

In the web.config for the particular site that I want to be accessed via https, and to have http rewritten to http, I set this:

<rewrite>
  <rules>
    <rule name="Redirect to HTTPS" stopProcessing="true">
      <match url="(.*)" />
      <conditions>
        <add input="{HTTPS}" pattern="^OFF$" />
      </conditions>
      <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Permanent" />
    </rule>
  </rules>
</rewrite>
bgmCoder
  • 706
  • 4
  • 16
  • 29