IIS URL重写-为什么我的QueryString追加不一致?

时间:2019-12-03 23:48:47

标签: iis url-rewriting

我正在尝试使用IIS URL重写做一些事情,其中​​之一是采用用户提供的子域,并将子域文本作为查询字符串附加(实际上,我正在使用它来分隔用户文件)。在某些情况下,有些奇怪的事情发生了。

我有一些链接,它们的反应不同,输入时返回不同的值。

  1. http://something.domain.com/courses
    • 重定向到http://something.domain.com/courses/?subdomain=something 意外
  2. http://something.domain.com/courses/
    • 按预期重定向到http://something.domain.com/courses/ (或者我希望如此)
  3. http://something.domain.com/courses/list
    • 按预期重定向到http://something.domain.com/courses/list (或者我希望如此)

这的主要问题是由于某种原因,在第一个示例中发送?subdomain=something时,我的代码无法正确响应。它基本上删除参数。我遇到的另一个问题是,它看起来很难看,因为它仅在某些用例中发生,并且在最常见的用例中(发生问题的人会使用/?)< / p>

当我查看我的管理页面时,也会发生类似的情况,但是,在3种情况下,有2种意外返回

  1. http://something.domain.com/admin/
    • 返回http://something.domain.com/admin/?subdomain=something#/ 意外
  2. http://something.domain.com/admin
    • 返回http://something.domain.com/admin/?subdomain=something#/ 意外
  3. http://something.domain.com/admin/#/
    • 按预期返回http://something.domain.com/admin/#/

由于Admin示例中没有附加规则,因此我认为它与子域规则有关,但是我不知道它是什么。

注释

我尝试使用appendQueryString="true"appendQueryString="false"

我在子域规则上使用stopProcessing="false",因为它应应用于每个请求。


子域重写规则

<rule name="RewriteSubdomainToQuery" stopProcessing="false">
    <match url="(.*)" />
    <conditions>
        <add input="{HTTP_HOST}" pattern="^(www\.)*(\w+)\.(.*)(\.com)" />
    </conditions>
    <action type="Rewrite" url="{R:1}?subdomain={C:2}" appendQueryString="false" />
</rule>

课程改写规则

<rule name="RewriteCoursesHandler" stopProcessing="true">
    <match url="^courses/?([^/]*)$" />
    <conditions>
        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
    </conditions>
    <action type="Rewrite" url="courses/index.asp?view={R:1}" />
</rule>

0 个答案:

没有答案
相关问题