0

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)?

JGW
  • 57
  • 2
  • 5

2 Answers2

0

Perhaps you could try this:

# 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]
Mike Rockétt
  • 8,947
  • 4
  • 45
  • 81
0

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]
TonyCool
  • 1,004
  • 1
  • 6
  • 5