使用其他操作重写URL


URL rewriting with other actions

我目前有一个PHP web应用程序,接受url为:/page。3、索引文件得到编号,并使用它:

/page.3 > $_GET['id'] = 3

IIS URL重写模式为:

^([^/]+/)*([^/]+/)'.('d+)$

生成index.php?id={R:3}

但是,我希望能够指定其他参数,例如

/page.3&do=4 > $_GET['id'] = 3 and $_GET['do'] = 4

是否有任何方法我可以做到这一点使用IIS重写或PHP?

由于某些原因,我无法让您的正则表达式匹配url中的/page.3等内容,因此我想出了自己的正则表达式:

<rewrite>
    <rules>
        <rule name="RWW" enabled="true" stopProcessing="true">
            <match url="((.+)'.('d+))" />
            <action type="Rewrite" url="index.php?id={R:3}" />
        </rule>
    </rules>
</rewrite>

默认情况下,重写器将附加您的查询字符串。