【问题标题】:wordpress post redirect rule not working IIS / coldfusionwordpress 后重定向规则不起作用 IIS/coldfusion
【发布时间】:2017-12-20 14:10:39
【问题描述】:

我正在尝试使用 IIS URL 重定向将 wordpress 帖子重定向到 Coldfusion 页面。帖子链接是

domain.com/?p=345

所以我使用滚动模式设置了以下重定向

/?p=([0-9]+)

指向下一页...

/blog.cfm?ID={R:1}

但遗憾的是,当我查看该页面时,它只是刷新,并没有重定向到 blog.cfm 页面。

非常感谢任何帮助或建议。

下面是完整的 web.config

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
    <rewrite>
        <rules>
            <rule name="wp post redirect" stopProcessing="true">
                <match url="/?p=([0-9]+)" />
                <action type="Redirect" url="blog.cfm?ID={R:1}" />
            </rule>
        </rules>
    </rewrite>
</system.webServer>
</configuration>

【问题讨论】:

  • 能否在您的问题中添加来自 web.config 的重定向规则
  • 嗨,我现在已经添加了 web.config。谢谢

标签: wordpress iis url-rewriting coldfusion


【解决方案1】:

你的规则应该是这样的:

<rule name="wp post redirect" stopProcessing="true">
    <match url="^$" />
    <conditions>
        <add input="{QUERY_STRING}" pattern="p=([0-9]+)" />
    </conditions>
    <action type="Redirect" url="blog.cfm?ID={c:1}" appendQueryString="false" />
</rule>

说明:

您的规则有错误&lt;match url= 只包含没有查询字符串的 url 路径。

&lt;match url="^$" /&gt; 表示对请求应用此规则,对^$ 正则表达式有效。仅用于主页

&lt;add input="{QUERY_STRING}" pattern="p=([0-9]+)" /&gt; 表示应用此条件。仅当查询字符串对p=([0-9]+) regexp 有效时

&lt;action type="Redirect" url="blog.cfm?ID={c:1}" appendQueryString="false" /&gt; 重定向到log.cfm?ID={c:1},其中{c:1} 是来自条件的正则表达式的第一个匹配项

【讨论】:

  • 非常感谢维克多,现在这是一种享受。我现在要 IIS Url Rewrite,但似乎是一个非常有用的工具。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-08-10
  • 2016-02-25
  • 2018-08-25
相关资源
最近更新 更多