0

互いに競合している URL 書き換えルールに関して、次のような状況があります。

  1. ルール 1: ドメインを https にリダイレクトする必要がある
  2. ルール 2: www.mydomain.com --> https://mydomain.comにリダイレクトする必要がある
  3. ルール 3: https://mydomain.com/myfolderにリダイレクトするには www.mydomain.com と mydomain.com の両方が必要ですが、 mydomain.com/mysecondfolder がある場合は、 https://mydomain.com/mysecondfolder にのみリダイレクトする必要があります

私が達成できたのは、www.mydomain.com をhttps://mydomain.comにリダイレクトする以外のすべてです (単独で機能している場合、別のルールと競合しているという理由だけで)。

私のルールは次のとおりです。

<rule name="HTTP to HTTPS redirect" stopProcessing="true">
              <match url="(.*)" />
                <conditions>
                    <add input="{HTTPS}" pattern="off" />
                </conditions>
              <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Permanent" />
            </rule> 

            <rule name="redirect to myfolder" enabled="true">
                <match url="^$" />
                <conditions>
                    <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                </conditions>
                <action type="Rewrite" url="/myfolder" />
            </rule>
4

1 に答える 1

0

以下のルールを使用してこれを解決できました。

<rewrite>
            <rules>
            <rule name="Canonical Host Name" enabled="true" stopProcessing="true">
              <match url="(.*)" />
              <conditions>
                <add input="{HTTP_HOST}" negate="true" pattern="^myapp\.com$" />
              </conditions>
              <action type="Redirect" url="http://myapp.com/{R:1}" redirectType="Permanent" />
            </rule>
                <rule name="HTTP to HTTPS redirect" enabled="true" stopProcessing="true">
                  <match url="(.*)" />
                    <conditions>
                        <add input="{HTTPS}" pattern="off" />
                    </conditions>
                  <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Permanent" />
                </rule> 
                <rule name="redirect to items" enabled="false">
                    <match url="^$" />
                    <conditions>
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="/items" />
                </rule>

            </rules>
        </rewrite>
于 2012-10-12T08:52:23.353 に答える