在 PHP 的 web.config 中重写查询字符串 url


Rewrite query string url in web.config in PHP

我想重定向网址 From http://example.com/page-name/?id=45 到 http://example.com/page-name/45在 IIS 中的 web.config 中。我怎样才能为 web.config 编写规则?

我正在使用以下代码

<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 错误。 这段代码有什么问题?