2

我们已经将我们的站点从一个 php apache 站点移动到一个 asp.net mvc 站点,我正在尝试让特定的重定向工作,但我被卡住了。

基本上我希望对http://www.mysite.com/index.php?pr=about_us的任何请求都被重定向到http://www.mysite.com/About-Us

我已经尝试过了,但它不起作用。有任何想法吗?

<rewrite>
  <rules>
    <rule name="About Us" stopProcessing="true">
      <match url="index.php?pr=About_Us" ignoreCase="false" />
      <action type="Redirect" redirectType="Permanent" url="http://www.mysite.com/About-Us" />
    </rule>
  </rules>
</rewrite>

我也试过这个,但也没有用。

<httpRedirect enabled="true" exactDestination="true" httpResponseStatus="Permanent">
    <add wildcard="index.php?pr=About_Us" destination="/About-Us" />
</httpRedirect>

我有大约十几个这样的特定重定向,我需要对不同的页面实施这些重定向。

任何帮助是极大的赞赏!谢谢

4

1 回答 1

3

试试这个:

<rule name="About Us" stopProcessing="true">
    <match url="^(.*)$">
        <conditions>
            <add input="{URL}" pattern="index.php?pr=About_Us" />
        </conditions>
    </match>
    <action type="Redirect" redirectType="Permanent" url="http://www.mysite.com/About-Us" />
</rule>

编辑

这是条件的另一种可能性:

<conditions logicalGrouping="MatchAll">
    <add input="{QUERY_STRING}" pattern="?pr=About_Us" />
    <add input="{REQUEST_FILENAME}" pattern="index.php" />
</conditions>

编辑 - 工作解决方案

<rule name="About Us" stopProcessing="true">
  <match url="^(.*)$" />
    <conditions logicalGrouping="MatchAll">
      <add input="{QUERY_STRING}" pattern="/?pr=About_Us$" />
      <add input="{REQUEST_FILENAME}" pattern="index.php" />
    </conditions>
    <action type="Redirect" redirectType="Permanent" url="http://www.mysite.com/About-Us" />
</rule>
于 2012-05-14T01:53:10.910 回答