如何网址重定向只有在IIS具体参数 [英] How to redirect a url only with specific parameters in IIS
问题描述
我有一个网址,看起来像这样:
I have a url that looks like this:
www.mywebsite.com/page.aspx?code=1.a
我想通过IIS重定向此URL:
I want to redirect this URL via IIS to:
www.mywebsite.com/page.aspx?code=1.b
我想通过IIS,而不是code范围内做到这一点。
I would like to do this through IIS and not within the code.
我有一个看起来像其他各种网站网址:
I have various other website urls that look like:
www.mywebsite.com/page.aspx?code=2
www.mywebsite.com/page.aspx?code=3.a
www.mywebsite.com/page.aspx?code=6.c
我不希望这些受到影响。
I don't want these to be affected.
感谢。
推荐答案
这是简单的方法在IIS 7.5中做,这是到 URL重写微软扩展安装到IIS。
An easy way to do this in IIS 7.5 is to install the URL Rewrite extension from Microsoft into IIS.
http://www.iis.net/downloads/microsoft/url-rewrite
一旦你安装它,你可以添加规则,从?code = 1.A
重定向到?code = 1.B
。在IIS中,你会看到一个名为 URL重写
在 IIS
为您的网站的标题新的条目。您可以使用编辑器那里创建新规则。一旦规则被创建,它会被写入到的web.config
文件。
Once you have it installed, you can just add a rule to redirect from ?code=1.a
to ?code=1.b
. In IIS, you'll see a new entry called URL Rewrite
under the IIS
heading for your website. You can use the editor there to create a new rule. Once the rule is created, it will be written into your web.config
file.
在的web.config
文件,规则应该是这个样子:
In the web.config
file, the rule should look something like this:
<system.webServer>
...
<rewrite>
<rules>
<rule name="Code=1.a redirect" patternSyntax="ExactMatch"
stopProcessing="true">
<match url="page.aspx" />
<action type="Redirect" url="page.aspx?code=1.b"
appendQueryString="false" redirectType="Permanent" />
<conditions>
<add input="{QUERY_STRING}" pattern="code=1.a" />
</conditions>
</rule>
</rules>
</rewrite>
...
</system.webServer>
这篇关于如何网址重定向只有在IIS具体参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!