2012-03-27 1 views
4

web.configにこのルールを追加して、www以外のURLをwwwにリダイレクトしました。ファイルを発行するためにwww以外のルールをリダイレクトする

<rule name="Redirect to WWW" stopProcessing="true"> 
      <match url=".*" /> 
      <conditions> 
      <add input="{HTTP_HOST}" pattern="^example.com$" /> 
      </conditions> 
      <action type="Redirect" url="http://www.example.com/{R:0}" redirectType="Permanent" /> 
     </rule> 

メインサイトURLは正常に動作していますが、それは

http://www.example.com/userfiles/abc.pdf

ようないくつかのURL http://www.example.com

にでものためにリダイレクトするユーザーの種類http://example.com場合、それはここで

http://www.www.example.com/userfiles/abc.pdf

にリダイレクトするようにあなたは、URLで2時間WWWを見ることができます。

答えて

1

私はこの1つが動作する必要がありますね:

<rule name="Redirect to WWW" stopProcessing="true"> 
    <match url="(.*)" /> 
    <conditions> 
    <add input="{HTTP_HOST}" pattern="^www\.example\.com$" negate="true" /> 
    </conditions> 
    <action type="Redirect" url="http://www.example.com/{R:1}" /> 
</rule> 

予想通りこの1つは動作しない場合は、別の条件を追加しようとすることができます:

<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> 

は、この情報がお役に立てば幸いです。

関連する問題