我正在尝试使用IIS URL重写做一些事情,其中之一是采用用户提供的子域,并将子域文本作为查询字符串附加(实际上,我正在使用它来分隔用户文件)。在某些情况下,有些奇怪的事情发生了。
我有一些链接,它们的反应不同,输入时返回不同的值。
http://something.domain.com/courses
http://something.domain.com/courses/?subdomain=something
意外 http://something.domain.com/courses/
http://something.domain.com/courses/
(或者我希望如此)http://something.domain.com/courses/list
http://something.domain.com/courses/list
(或者我希望如此)这的主要问题是由于某种原因,在第一个示例中发送?subdomain=something
时,我的代码无法正确响应。它基本上删除参数。我遇到的另一个问题是,它看起来很难看,因为它仅在某些用例中发生,并且在最常见的用例中(发生问题的人会使用/
?)< / p>
当我查看我的管理页面时,也会发生类似的情况,但是,在3种情况下,有2种意外返回
http://something.domain.com/admin/
http://something.domain.com/admin/?subdomain=something#/
意外 http://something.domain.com/admin
http://something.domain.com/admin/?subdomain=something#/
意外 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>