2013-04-09 147 views
2

我有我的站点的域别名。我想知道如何为domainA.ext请求重定向到https://domainA.ext/folderA和domainB.ext请求到http://domainB.ext/folderBWeb.config将一个域重定向到非https文件夹,另一个域重定向到https文件夹

目前我有以下规则来重定向所有的HTTP请求到https,但它会将所有的请求到https:

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

它是Windows服务器2008年,但我的cms是在PHP中。

+0

你可以定义所有案件和预期结果?例如,如果有人点击“http:// domainB.ext”会怎么样?他们是否必须重定向到“http:// domainB.ext/folderB”或保留在“http:// domainB.ext”? – cheesemacfly 2013-04-09 20:04:02

+0

'http:// domainB.ext/folderB'会做。 – ImproperUsername 2013-04-09 20:12:31

回答

3

我想不出比4种不同规则更简单的事情。

domainA.ext 2.第一批:

<rule name="Check path folderA" stopProcessing="true"> 
    <match url="^folderA" negate="true" /> 
    <conditions logicalGrouping="MatchAll"> 
     <add input="{HTTP_HOST}" pattern="domainA\.ext$" /> 
    </conditions> 
    <action type="Redirect" url="https://domainA.ext/folderA/" /> 
</rule> 
<rule name="Check SSL for domainA" stopProcessing="true"> 
    <match url="(.*)" /> 
    <conditions logicalGrouping="MatchAll"> 
     <add input="{HTTP_HOST}" pattern="domainA\.ext$" /> 
     <add input="{HTTPS}" pattern="^OFF$" /> 
    </conditions>       
    <action type="Redirect" url="https://domainA.ext/folderA/" /> 
</rule> 
  • 第1章:如果路径不folderA开始,然后将其重定向到https://domainA.ext/folderA/
  • 第二个规则:如果HTTPS是关闭的,它重定向到https://domainA.ext/folderA/

而对于domainB.ext 2分未来的:

<rule name="Check path folderB" stopProcessing="true"> 
    <match url="^folderB" negate="true" /> 
    <conditions logicalGrouping="MatchAll"> 
     <add input="{HTTP_HOST}" pattern="domainB\.ext$" /> 
    </conditions> 
    <action type="Redirect" url="http://domainB.ext/folderB/" /> 
</rule> 
<rule name="Check no SSL for domainB" stopProcessing="true"> 
    <match url="(.*)" /> 
    <conditions logicalGrouping="MatchAll"> 
     <add input="{HTTP_HOST}" pattern="domainB\.ext$" /> 
     <add input="{HTTPS}" pattern="^ON$" /> 
    </conditions>       
    <action type="Redirect" url="http://domainB.ext/folderB/" /> 
</rule> 
  • 第1章:如果路径不folderB开始,然后将其重定向到http://domainB.ext/folderB/
  • 第二个规则:如果HTTPS是,它重定向到http://domainB.ext/folderB/
+0

太棒了!非常感谢你,这个作品非常漂亮。我很欣赏这一点。 – ImproperUsername 2013-04-09 23:31:04

+0

不要忘记接受答案,如果它帮助你:) – cheesemacfly 2013-04-09 23:59:18

+1

谢谢你接受答案的提示;我现在已经接受你的。 – ImproperUsername 2013-04-10 02:15:46

相关问题