<httpRedirect/> - 匹配包含字符串的 URL
<httpRedirect/> - match URL containing string
我想将包含特定字符串的每个 URL 重定向到 https://example.com/. I am using IIS with HTTP Redirect installed,并且我已将规则添加到我的 Web.config。
<httpRedirect enabled="true" exactDestination="true" httpResponseStatus="Found">
<add wildcard="*" destination="https://example.com/" />
</httpRedirect>
问题是 wildcard="*"
有效,但 wildcard="*foo*"
不会重定向包含 foo
的 URL,例如 https://localhost/?foo=true
.
我怎样才能让它适用于“*”以外的通配符?
它使用 UrlRewrite 模块而不是 HttpRedirect。
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="MyRule" patternSyntax="ECMAScript" stopProcessing="true">
<match url="^folder/Default.aspx$" />
<action
type="Redirect"
url="folder/Default.aspx?&variable1=ffff&variable2=gggg"
appendQueryString="false"
redirectType="Found" />
<conditions logicalGrouping="MatchAny">
<add input="{QUERY_STRING}"
pattern="^&variable1=eeee&variable2=aaa$" />
<add input="{QUERY_STRING}"
pattern="^variable1=eeee&variable2=aaa$" />
</conditions>
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
我想将包含特定字符串的每个 URL 重定向到 https://example.com/. I am using IIS with HTTP Redirect installed,并且我已将规则添加到我的 Web.config。
<httpRedirect enabled="true" exactDestination="true" httpResponseStatus="Found">
<add wildcard="*" destination="https://example.com/" />
</httpRedirect>
问题是 wildcard="*"
有效,但 wildcard="*foo*"
不会重定向包含 foo
的 URL,例如 https://localhost/?foo=true
.
我怎样才能让它适用于“*”以外的通配符?
它使用 UrlRewrite 模块而不是 HttpRedirect。
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="MyRule" patternSyntax="ECMAScript" stopProcessing="true">
<match url="^folder/Default.aspx$" />
<action
type="Redirect"
url="folder/Default.aspx?&variable1=ffff&variable2=gggg"
appendQueryString="false"
redirectType="Found" />
<conditions logicalGrouping="MatchAny">
<add input="{QUERY_STRING}"
pattern="^&variable1=eeee&variable2=aaa$" />
<add input="{QUERY_STRING}"
pattern="^variable1=eeee&variable2=aaa$" />
</conditions>
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>