Iis 如何在Windows Server 2008 R2上使用web.config重定向到查询字符串?

Iis 如何在Windows Server 2008 R2上使用web.config重定向到查询字符串?,iis,redirect,url-rewriting,iis-7.5,windows-server-2008-r2,Iis,Redirect,Url Rewriting,Iis 7.5,Windows Server 2008 R2,我想在运行Windows server 2008 R2的IIS 7.5服务器上使用web.config执行重定向。我只想用一个很长的查询字符串为另一个URL创建一个快捷URL: www.example.com/redirect->www.example.com/long_url.aspx?key1=value1&key2=value2 但是,当我将以下重写规则添加到web.config时,会出现500个内部服务器错误: <configuration> <system.w

我想在运行Windows server 2008 R2的IIS 7.5服务器上使用web.config执行重定向。我只想用一个很长的查询字符串为另一个URL创建一个快捷URL:

www.example.com/redirect->www.example.com/long_url.aspx?key1=value1&key2=value2

但是,当我将以下重写规则添加到web.config时,会出现500个内部服务器错误:

<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="^redirect$" stopProcessing="true">
                    <match url="^redirect$" />
                    <action type="Redirect" url="/long_url.aspx?key1=value1&key2=value2" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>


我需要更改什么才能使其正常工作?

在重写规则操作中添加查询字符串时,必须转义URL中的所有“?”和“&”字符

  • “?”=“?;”
  • &“=”和
以下代码将起作用:

<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="^redirect$" stopProcessing="true">
                    <match url="^redirect$" />
                    <action type="Redirect" url="/long_url.aspx&#63;key1=value1&amp;key2=value2" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>