我在 winhost 上托管一个站点,并且我正在使用 IIS URLRewrite 来允许将主机上的子文件夹映射到子域。
IE
~/
〜/我的应用程序/
~/KenticoCMS/
使用根 web.config 中的 IIS URL 重写规则将“mydomain.com”的请求路由到 ~/KenticoCMS/ 并将“myapp.mydomain.com”的请求路由到 ~/myapp/
目前,当我禁用重写时,mydomain.com/KenticoCMS/ 会正常运行。
但是,当我启用重写时,出现异常:
[ArgumentOutOfRangeException: startIndex cannot be larger than length of string. Parameter name: startIndex]
System.String.InternalSubStringWithChecks(Int32 startIndex, Int32 length, Boolean fAlwaysCopy) +10698899
CMS.URLRewritingEngine.URLRewriter.CheckPermissions(String siteName, PageInfo pi, Boolean excludeSystem) +235
CMSAppBase.CheckSecurity() +775
CMSAppBase.CMSAcquireRequestState(Object sender, EventArgs e) +606
CMS.CMSHelper.CMSApplicationModule.app_AcquireRequestState(Object sender, EventArgs e) +22
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +136
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +69
任何人对如何配置站点以使其可以在此设置中工作有任何建议吗?
编辑从根文件夹添加 web.config 并重写代码:
但是,我相信问题在于 Kentico 应用程序认为它位于子文件夹(它是)中,但没有通过 URL 获取该子文件夹。
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<rewrite>
<rules>
<rule name="Rewrite to Kentico" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="^mydomain.com$" />
</conditions>
<action type="Rewrite" url="KenticoCMS/{R:1}" />
</rule>
<rule name="Rewrite to Myapp" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="^myapp.mydomain.com$" />
</conditions>
<action type="Rewrite" url="myapp/{R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>