【问题标题】:Rewrite query string url in web.config in PHP在 PHP 中重写 web.config 中的查询字符串 url
【发布时间】:2014-12-08 11:44:09
【问题描述】:

我想重定向网址来自 http://example.com/page-name/?id=45http://example.com/page-name/45 在 IIS 的 web.config 中。 如何为 web.config 编写规则?

【问题讨论】:

    标签: php wordpress iis web.config-transform


    【解决方案1】:

    我正在使用下面的代码

    <rule name="Redirect to url" stopProcessing="true">
        <match url=".*" />
            <conditions>
            <add input="{HTTP_HOST}" pattern="^page-name/([^/]+)/?$" />
                </conditions>
            <action type="Redirect" url="page-name/?id={R:0}" redirectType="Permanent" />
     </rule>
    

    但如果我使用此代码,我会收到 404 错误。这段代码有什么问题?

    【讨论】:

    • 尝试 {R:1} 而不是 {R:0}
    猜你喜欢
    • 1970-01-01
    • 2023-03-04
    • 2012-06-16
    • 2015-03-14
    • 2012-09-19
    • 2011-08-02
    • 2012-01-18
    • 1970-01-01
    相关资源
    最近更新 更多