IIS7多站點ssl配置及http自動跳轉到https


SSL證書配置參考如下:

http轉https實戰教程iis7.5

window08 IIS7安裝多域名SSL證書綁定443端口

關鍵是修改C:\Windows\System32\inetsrv\config\applicationHost.config配置在443后面加上指定的域名

http跳轉https,參考如下:

https://www.cnblogs.com/wer-ltm/p/10190535.html

https://www.cnblogs.com/xiaohi/p/8038042.html

關鍵代碼:

<system.webServer>
   <rewrite>
     <rules>
       <rule name="HTTP to HTTPS redirect" stopProcessing="true">
         <match url="(.*)" />
         <conditions>
           <add input="{HTTPS}" pattern="off" ignoreCase="true" />
         </conditions>
         <action type="Redirect" redirectType="Found" url="https://{HTTP_HOST}/{R:1}" />
       </rule>
     </rules>
   </rewrite>
 </system.webServer>

如果一個站點綁定多個域名(未必是子域名):

a.domain.com

b.domain.com

c.domain.com

我們只需要子域名a跳轉,參考如下:

IIS rewrite rule to redirect specific domain url to different url on same domain

則配置如下:

<rewrite>
  <rules>
    <rule name="redirect" enabled="true">
      <match url="(.*)" />
      <conditions>
        <add input="{HTTPS}" pattern="off" />
        <add input="{HTTP_HOST}" pattern="^a\.domain\.com$" />
      </conditions>
      <action type="Redirect" url="https://a.domain.com/{R:1}" appendQueryString="true" redirectType="Permanent" />
    </rule>
  </rules>
</rewrite>

 IIS配置不帶www跳轉到www,參考如下:IIS7設置將域名不帶www跳轉到帶www上

主要配置如下:

        <rewrite>
            <rules>
                <rule name="www" stopProcessing="true">
                    <match url="^(.*)" ignoreCase="false" />
                    <conditions logicalGrouping="MatchAll">
                        <add input="{HTTP_HOST}" pattern="^(domain\.com)(:80)?" />
                    </conditions>
                    <action type="Redirect" url="http://www.domain.com/{R:1}" redirectType="Permanent" />
                </rule>
            </rules>
        </rewrite>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM