2017-10-19 12 views
1

にリダイレクト現在、私のルールは次のとおりです。のWeb.config URLは非WWW + HTTPS

<rule name="SecureRedirect" stopProcessing="true"> 
    <match url="^(.*)$" /> 
    <conditions> 
    <add input="{HTTPS}" pattern="off" /> 
    <add input="{HTTP_HOST}" pattern="^(www\.)?(.*)$" /> 
    </conditions> 
    <action type="Redirect" url="https://{C:2}" redirectType="Permanent" /> 
</rule> 

問題はここにある:

http://www.domainName.com/image.pnghttps://domainName.com 代わりのhttps://domainName.com/image.png

に誤ってリダイレクトし、

https://www.domainName.com/image.pngにリダイレクトされません3210

したがって、www以外のhttps URLにすべてリダイレクトする真の方法は何ですか?

答えて

0

次のように私は自分のサイト上でそれをやった方法は次のとおりです。

ServerName www.example.com 
ServerAlias example.com 
Redirect/https://www.example.com/ 
+0

web-config環境でこれが意味することを理解できません! – user3196160

+2

この回答はIIS用ではありません –

0

は、このルールを試してみてください:

<rule name="SecureRedirect" stopProcessing="true"> 
    <match url="(.*)" /> 
    <conditions logicalGrouping="MatchAny"> 
     <add input="{HTTPS}" pattern="^OFF$" /> 
    </conditions> 
    <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" /> 
</rule> 
0

すべての要件に適合します正しいルールは、次のとおりです。

<rule name="SecureRedirect" stopProcessing="true"> 
    <match url="(.*)" /> 
    <conditions logicalGrouping="MatchAny"> 
     <add input="{HTTP_HOST}" pattern="^(www\.)?(.*)$" /> 
     <add input="{HTTPS}" pattern="off" /> 
    </conditions> 
    <action type="Redirect" url="https://{C:2}/{R:1}" redirectType="Permanent" /> 
</rule> 
関連する問題