子文件夹中的Kentico应用程序和IIS URL重写?

子文件夹中的Kentico应用程序和IIS URL重写?,iis,url-rewriting,kentico,Iis,Url Rewriting,Kentico,我在winhost上托管一个站点,并使用IIS URLRewite允许将主机上的子文件夹映射到子域 i、 e ~/ ~/myapp/ ~/Kenticoms/ 使用根web.config中的IIS URL重写规则,将“mydomain.com”的请求路由到~/KenticoCMS/,并将“myapp.mydomain.com”的请求路由到~/myapp/ 目前,当我禁用重写时,mydomain.com/kenticoms/显示良好 但是,当我启用重写时,会出现一个异常: [ArgumentOut

我在winhost上托管一个站点,并使用IIS URLRewite允许将主机上的子文件夹映射到子域

i、 e

~/

~/myapp/

~/Kenticoms/

使用根web.config中的IIS URL重写规则,将“mydomain.com”的请求路由到~/KenticoCMS/,并将“myapp.mydomain.com”的请求路由到~/myapp/

目前,当我禁用重写时,mydomain.com/kenticoms/显示良好

但是,当我启用重写时,会出现一个异常:

[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>

所以这是一个相当古老的问题,但简短的回答是,我认为你的假设是正确的,Kentico不喜欢URL以这种方式更改

我以前也做过类似的事情,如果其他人有这个问题,应该会有帮助,但它会重定向而不是重写

我设置了以下规则:

<rule name="all subdomains" stopProcessing="true">
  <match url=".*" />
  <conditions>
    <add input="{HTTP_HOST}" pattern="(myapp)\.example\.com" />
  </conditions>
  <action type="Redirect" url="http://example.com/{C:1}{URL}" redirectType="Found" />
</rule>

显然,你可以改变重定向类型,等等。但关键是它是一个重定向,而不是重写,所以它不完全是你在原始问题中所指的


但是,假设您拥有/拥有子域的有效许可证密钥,我不确定您为什么需要或希望通过重写来实现这一点,因为您可以在每个子域中设置一个IIS站点。

您可以显示您的重写代码吗?@JonoRR我编辑为post以包含重写规则