【发布时间】:2012-11-10 12:46:11
【问题描述】:
在我的网站上,我的 URL 有时会得到一个查询字符串参数,该参数由我们的外部系统附加。
因此,它的 URL 不是像这样:http://www.domain.com?myquery=blah 或 http://www.domain.com,而是具有 URL http:http://www.domain.com?myquery=blah&theirpara=blah 或 http://www.domain.com?theirpara=blah。
当用户使用“theirpara”参数访问时,我想在没有它的情况下对 URL 进行 301 重定向。
我尝试使用 URL 重写模块,但没有真正到达任何地方。如果可能的话,最好在 IIS/web.config 级别而不是 Response.RedirectPermanent 级别执行此操作。
我认为使用规则(URL 写入模块)进行设置会很好,但老实说,我不知道如何解决这个问题。我正在使用以下规则来删除尾部斜杠,但不确定如何根据需要对其进行修改。
<!--To always remove trailing slash from the URL-->
<rule name="Remove trailing slash" stopProcessing="true">
<match url="(.*)/$" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Redirect" redirectType="Permanent" url="{R:1}" />
</rule>
关于如何设置它的任何想法?
【问题讨论】:
-
他们的参数有什么问题,要删除吗?
-
Uriil:搜索引擎优化目的 :) 它在 Google 中被编入索引,给了我重复的内容。它可以用规范的网址修复,但我想要两种解决方案
标签: c# asp.net iis web-config url-rewrite-module