.htaccessisapi-rewritehelicontech

ISAPI Rewrite Rule For Multiple Query String Parameters


I'm trying to rewrite a URL with 2 query string parameters using HeliconTech ISAPI_Rewrite Version 3. I'm able to rewrite the URL with 1 parameter but I can't figure out the rule(s) for rewriting 2.

Original URL:

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

Desired rewritten URL

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

My current .htaccess:

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

My current .htaccess file successfully rewrites the first parameter (id). My question is how do I modify the rule or add an extra rule to also rewrite the 2nd parameter (name)?


Solution

  • Should be like this:

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