0

サーバーに URL 書き換えモジュール 2.0 をインストールしました。ユーザーがログインまたは登録ビューに移動している場合、ユーザーを http から https に切り替える次のルールがあります。

<rewrite>
      <rules>
        <rule name="Redirect to SSL for login and register" stopProcessing="true">
          <match url="^login.aspx$|^register.aspx$" />
          <conditions>
            <add input="{HTTPS}" pattern="^OFF$" />
          </conditions>
          <action type="Redirect" url="https://{HTTP_Host}/{R:0}" />
        </rule>
      </rules>
    </rewrite>

このようにして、ユーザーが http でログインまたは登録ページにアクセスしようとすると、関連する https ページに切り替えられます。しかし、ユーザーがhttps://server.com/login.aspxを使用してログインしたら、http に戻るようにします。正確には、ログインと登録以外のすべてのページを強制的に http にするというルールを書きたいと思います。どうすればいいですか?登録ページとログインページ以外の正規表現を理解する必要があるだけだと思いますか?それはどのようなものでしょうか?私は正規表現に堪能ではありません。

4

1 に答える 1

1

どうですか:

<rewrite>
  <rules>
    <rule name="Redirect to SSL for login and register" stopProcessing="true">
      <match url="^login\.aspx$|^register\.aspx$" />
      <conditions>
        <add input="{HTTPS}" pattern="^OFF$" />
      </conditions>
      <action type="Redirect" url="https://{HTTP_Host}/{R:0}" />
    </rule>
    <rule name="Redirect to non-SSL for others" stopProcessing="true">
      <match url="^.*$" />
      <conditions>
        <add input="{HTTPS}" pattern="^ON$" />
      </conditions>
      <action type="Redirect" url="http://{HTTP_Host}/{R:0}" />
    </rule>
  </rules>
</rewrite>
于 2012-07-26T13:49:00.103 に答える