2017-05-13 13 views
1

私がする必要があるのは、すべてのリクエストをhttpsとwww以外のURLにリダイレクトすることです。例: -http:// example .com/something#hash - > https:// example .com/something#hash - https://www。例.com/something#hash - > https:// example .com/something#hash - http://www。例.COM /何かの#ハッシュ - > https://で例.COM /何かの#ハッシュ私がやったと動作しません何Web.config httpsと非wwwにすべてリダイレクト

...:

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

    <rule name="Redirect to non-www" stopProcessing="true"> 
     <match url="(.*)"></match> 
     <conditions> 
     <add input="{HTTP_HOST}" pattern="^example.com$" negate="true"></add> 
     </conditions> 
     <action type="Redirect" url="https://example.com/{R:1}" redirectType="Permanent" /> 
    </rule> 
    </rules> 
    <outboundRules> 
    <rule name="Add Strict-Transport-Security when HTTPS" enabled="true"> 
     <match serverVariable="RESPONSE_Strict_Transport_Security" pattern=".*" /> 
     <conditions> 
     <add input="{HTTPS}" pattern="on" ignoreCase="true" /> 
     </conditions> 
     <action type="Rewrite" value="max-age=31536000" /> 
    </rule> 
    </outboundRules> 
</rewrite> 

感謝!

答えて

0

これを試してみてください:

<rule name="HTTP to HTTPS" enabled="true" patternSyntax="Wildcard" stopProcessing="true"> 
        <match url="*" /> 
        <conditions> 
         <add input="{HTTPS}" pattern="off" /> 
        </conditions> 
        <action type="Redirect" url="https://www.{HTTP_HOST}{REQUEST_URI}" redirectType="Found" /> 
       </rule> 
関連する問題