将特定页面重定向到 iis web.config 中的另一个特定页面

标签 redirect web-config

我们已将网站从 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>

我有大约十几个这样的特定重定向,我需要将它们实现到各个页面。

非常感谢任何帮助! 谢谢

最佳答案

试试这个:

<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>

关于将特定页面重定向到 iis web.config 中的另一个特定页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10576659/

相关文章:

redirect - 301 永久移动 - 重定向页面的新链接在哪里?

asp.net - HTTP 错误 500.52 - URL 重写模块错误

c# - 将 XML 字符串发送到 WCF 时出现 "The maximum string content length quota (8192) has been exceeded while reading XML data"错误

redirect - Nginx 万维网。到非 www。重定向不工作

java - 重定向后重做原始请求 getRequestDispatcher

redirect - 在 IIS7 中重写映射 - 不重定向

某些版本的 IE 中的 JavaScript 重定向问题

java - 构建后从文件启动的自定义密码策略

php - Azure 和 CakePHP 3 位于子目录中

asp.net-mvc-4 - 如何将应用程序设置从 web.config 插入 View 模板