【发布时间】:2013-09-15 23:11:40
【问题描述】:
我在 winhost 上托管一个站点,并且我正在使用 IIS URLRewrite 来允许将主机上的子文件夹映射到子域。
即
~/
~/myapp/
~/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>
【问题讨论】:
-
你能展示你的重写代码吗?
-
@JonoRR 我编辑发布以包含重写规则
标签: iis url-rewriting kentico