0

IIS構成で2つのルールに従う必要があります(scottguによる):

<rule name="RemoveTrailingSlashRule1" stopProcessing="true">
    <match url="(.*)/$" />
    <conditions>
        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
    </conditions>
    <action type="Redirect" url="{R:1}" />
</rule>

<rule name="CanonicalHostNameRule1" enabled="true">
    <match url="(.*)" />
    <conditions>
        <add input="{HTTP_HOST}" pattern="^dev\.testing\.ch$" negate="true" />
    </conditions>
    <action type="Redirect" url="http://dev.testing.ch/{R:1}" />
</rule>

CanonicalHostNameRule1は、すべてのhttp://testing.chhttp://www.testing.ch/に転送します。

そして2番目のルールはバックスペースを削除します/

空のtesting.chリクエストをwww.testing.ch(バックスペースなし)に転送できればもっと良いでしょう。しかし、このように削除しただけでは、明らかに機能しません。

<action type="Redirect" url="http://dev.testing.ch{R:1}" />
4

1 に答える 1

0

ルールに問題はありません。http://www.testing.ch/のリクエストは最初のルールでキャッチされないため、これらを組み合わせる必要はありません。これは/、ドメイン名の後の最初の名前が、正規表現と照合されるURLの一部ではないためです。

PS:これらのルールは、実際のWebサイトではなく、開発サイト(dev.testing.ch)からのものであると想定しています。

于 2012-11-16T20:07:24.383 に答える