【问题标题】:ISAPI Rewrite Rule For Multiple Query String Parameters多个查询字符串参数的 ISAPI 重写规则
【发布时间】:2015-05-24 08:16:13
【问题描述】:

我正在尝试使用 HeliconTech ISAPI_Rewrite 版本 3 重写带有 2 个查询字符串参数的 URL。我能够使用 1 个参数重写 URL,但我无法弄清楚重写 2 的规则。

原网址:

http://example.com/index.php?id=1234&name=John-Edward-Smith

所需的重写 URL

http://example.com/id/1234/name/John-Edward-Smith

我当前的 .htaccess:

RewriteEngine On
RewriteRule   ^id/(.+)$  index.php?id=$1   [L, NC]

我当前的 .htaccess 文件成功地重写了第一个参数 (id)。我的问题是如何修改规则或添加额外的规则来重写第二个参数(名称)?

【问题讨论】:

    标签: .htaccess isapi-rewrite helicontech


    【解决方案1】:

    应该是这样的:

    RewriteRule ^id/(\d+)/name/([^./]+)$ index.php?id=$1&name=$2 [NC,L]
    RewriteRule ^id/(\d+)$ index.php?id=$1 [NC,L]
    

    【讨论】:

      【解决方案2】:

      也许你可以试试这个:

      # Rewrite with the name
      RewriteRule ^id/(\d+)/name/([a-z0-9-]+)$ index.php?id=$1&name=$2 [L,NC]
      
      # Rewrite with only the ID
      RewriteRule ^id/(\d+)$ index.php?id=$1 [L,NC]
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2016-08-06
        • 1970-01-01
        • 2017-05-18
        • 2015-09-17
        • 2016-08-13
        • 2016-11-01
        • 2015-09-10
        相关资源
        最近更新 更多