【发布时间】:2016-07-19 00:58:25
【问题描述】:
我一直在使用以下模式为我的主站点和子域设置目录结构:
A.每个站点都在自己的子文件夹中,包括主站点,所以我有类似的东西
\wwwroot
\main
\subdomain1
B. wwwroot 中只有 1 个文件。具有以下内容的 web.config 文件
<configuration>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<rewrite>
<rules>
<rule name="Rewrite to folder1" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="^www.MyMainDomain.com$" />
</conditions>
<action type="Rewrite" url="main/{R:1}" />
</rule>
<rule name="subdomain1.MyMainDomain.com to sub folder" enabled="true" stopProcessing="true">
<match url="(.*)" ignoreCase="true" />
<conditions logicalGrouping="MatchAll">
<add input="{HTTP_HOST}" pattern="^subdomain1\.MyMainDomain\.com$" ignoreCase="false" />
<add input="{PATH_INFO}" pattern="^/subdomain1($|/)" negate="true" />
</conditions>
<action type="Rewrite" url="\subdomain1\{R:0}" />
</rule>
</rules>
</rewrite>
</system.webServer>
如何将 https 重定向仅添加到子域?
调试正在重写/重定向的内容的最佳方法是什么?
【问题讨论】:
-
你让它工作了吗?我有同样的问题,不知道如何处理。唯一的区别是我没有“主”,但只需要将 example.com/subdomain1 重定向到 subdomain1.example.com/subdomain1