1

サブドメインが存在しない場合にのみ前に www を追加するように以下の書き換えルールを変更する方法を知っている人はいますか?

<rule name="WWW Rewrite" enabled="true">
    <match url="(.*)" />
    <conditions>
        <add input="{HTTP_HOST}" negate="true" pattern="^www\.([.a-zA-Z0-9]+)$" />
    </conditions>
    <action type="Redirect" url="http://www.{HTTP_HOST}/{R:0}" appendQueryString="true" redirectType="Permanent" />
</rule>

ティア

4

1 に答える 1

1

これを書いて、IIS 7.5 ボックスでテストしました。「www」を追加するだけです。サブドメインがない場合。

<rule name="Redirect naked domains (that do NOT have a custom sub-domain) to www.domain.com" enabled="true" stopProcessing="true">
    <match url="(.*)" />
        <conditions logicalGrouping="MatchAll">
            <add input="{HTTP_HOST}" negate="true" pattern="^www\." />
            <add input="{HTTP_HOST}" pattern=".*\..*\.com" negate="true" />
        </conditions>
    <action type="Redirect" url="http://www.{HTTP_HOST}{REQUEST_URI}" appendQueryString="true" redirectType="Permanent" />
</rule>
于 2014-04-07T05:20:16.050 に答える