Web.config将一个域重定向到非https文件夹,另一个域重定向到https文件夹
我有我的站点的域别名。我想知道如何为domainA.ext请求重定向到https://domainA.ext/folderA
和domainB.ext请求到http://domainB.ext/folderB
Web.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中。
我想不出比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/
太棒了!非常感谢你,这个作品非常漂亮。我很欣赏这一点。 – ImproperUsername 2013-04-09 23:31:04
不要忘记接受答案,如果它帮助你:) – cheesemacfly 2013-04-09 23:59:18
谢谢你接受答案的提示;我现在已经接受你的。 – ImproperUsername 2013-04-10 02:15:46
你可以定义所有案件和预期结果?例如,如果有人点击“http:// domainB.ext”会怎么样?他们是否必须重定向到“http:// domainB.ext/folderB”或保留在“http:// domainB.ext”? – cheesemacfly 2013-04-09 20:04:02
'http:// domainB.ext/folderB'会做。 – ImproperUsername 2013-04-09 20:12:31