重写特定页面的规则以防止特定文化

Rewrite Rules for specific pages to prevent specific culture

我在我的 web.config 文件中为特定页面编写了重写规则,我想使用参数 url 将其从阿拉伯文化 'ar' 重定向到英语 'en' .

我目前的规则是

<rule name="Home page with parameter" stopProcessing="true">
<match url="^/ar/TestPage.aspx?id=10" />
<action type="Redirect" url="/en/TestPage.aspx?id={R:1}" />
</rule>

但是它不起作用。我可以通过其他任何方式实现这一目标吗?只有这个 (TestPage.aspx) 会被重定向。对于其他页面不需要。谢谢!

此规则将重定向:

/ar/TestPage.aspx/en/TestPage.aspx

/ar/TestPage.aspx?abc/en/TestPage.aspx?abc

/ar/TestPage.aspx?id=10/en/TestPage.aspx?id=10

<rule name="Home page with parameter" stopProcessing="true">
    <match url="^ar(/TestPage.aspx)" />
    <action type="Redirect" url="/en{R:1}" />
</rule>   

如果你只想在查询字符串有参数id时重定向,那么你需要像这样修改规则:

<rule name="Home page with parameter" stopProcessing="true">
    <match url="^ar(/TestPage.aspx)" />
    <conditions>
        <add input="{QUERY_STRING}" pattern="id=" />
    </conditions>
    <action type="Redirect" url="/en{R:1}" />
</rule>