2015-08-27 84 views
1

我們將ASP.NET應用程序託管爲Azure WebApp,並從GoDaddy配置域。我們爲非www域名購買了SSL。我們用下面的重定向規則:從「https:// www」重定向到「https://」

<rewrite> 
    <rules> 
    <rule name="Redirect to Example.com"> 
    <match url="(.*)"/> 
    <conditions> 
     <add input="{HTTP_HOST}" pattern="^(?!^Example.com)" /> 
    </conditions> 
    <action type="Redirect" url="https://Example.com/{R:1}"/> 
    </rule> 

    <rule name="Redirect to https"> 
    <match url="(.*)"/> 
     <conditions> 
     <add input="{HTTPS}" pattern="Off"/> 
     <add input="{REQUEST_METHOD}" pattern="^get$|^head$" /> 
     </conditions> 
     <action type="Redirect" url="https://{HTTP_HOST}/{R:1}"/> 
    </rule> 
</rules> 
</rewrite> 

有沒有辦法來添加另一個規則重定向請求「https://www」爲「https://」?

感謝,

周杰倫

回答

0

我與我的Windows主機,因爲我有一個通配符證書,並舉辦了幾個子域類似的挑戰。這裏是我放在一起的web.config,給它一個鏡頭,讓我知道!它似乎對我很好,但我的網站非常簡單。

<?xml version="1.0" encoding="UTF-8"?> 
<configuration> 
    <system.webServer> 
    <rewrite> 
     <rules> 
     <clear /> 

     <rule name="Redirect to https" stopProcessing="true"> 
      <match url="(.*)" /> 
      <conditions> 
      <add input="{HTTPS}" pattern="off" ignoreCase="true" /> 
      </conditions> 
      <action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" appendQueryString="false" /> 
     </rule> 

     <rule name="remove www" stopProcessing="true"> 
      <match url="(.*)" ignoreCase="true" /> 
      <conditions> 
      <add input="{HTTP_HOST}" pattern="^www\.YourDomain\.com$" /> 
      </conditions> 
      <action type="Redirect" url="https://YourDomain.com/{R:0}" redirectType="Permanent" /> 
     </rule> 

     </rules> 
    </rewrite> 
    </system.webServer> 
</configuration> 
相關問題