2011-08-14 35 views

回答

0

我研究並找到了我的答案。在條件中使用變量,我們可以使用{C:1}。 1表示第一場比賽。我爲這個轉換ecxact答案是:

 <rules> 
      <rule name="http Redirect" stopProcessing="true"> 
       <match url="^(.*)$" ignoreCase="false" /> 
       <conditions> 
        <add input="{HTTP_HOST}" pattern="^www\.(.*)$" /> 
        <add input="{SERVER_PORT_SECURE}" pattern="^0$" /> 
       </conditions> 
       <action type="Redirect" url="http://{C:1}/{R:1}" appendQueryString="true" redirectType="Permanent" /> 
      </rule> 
      <rule name="https Redirect" stopProcessing="true"> 
       <match url="^(.*)$" ignoreCase="false" /> 
       <conditions> 
        <add input="{HTTP_HOST}" pattern="^www\.(.*)$" /> 
        <add input="{SERVER_PORT_SECURE}" pattern="^0$" negate="true" /> 
       </conditions> 
       <action type="Redirect" url="https://{C:1}/{R:1}" appendQueryString="true" redirectType="Permanent" /> 
      </rule> 
     </rules> 

等於:

RewriteCond %{HTTP_HOST} ^www.(.+)$ [NC] 
RewriteCond %{HTTPS} ^off$ [NC] 
RewriteRule ^(.*)$ http://%1/$1 [L,QSA,R=302] 
RewriteCond %{HTTP_HOST} ^www.(.+)$ [NC] 
RewriteCond %{HTTPS} ^on$ [NC] 
RewriteRule ^(.*)$ https://%1/$1 [L,QSA,R=302] 

好運

相關問題