0

我正在尝试使用 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)。我的问题是如何修改规则或添加额外的规则来重写第二个参数(名称)?

4

2 回答 2

0

也许你可以试试这个:

# 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]
于 2015-05-24T08:39:25.270 回答
0

应该是这样的:

RewriteRule ^id/(\d+)/name/([^./]+)$ index.php?id=$1&name=$2 [NC,L]
RewriteRule ^id/(\d+)$ index.php?id=$1 [NC,L]
于 2015-05-24T11:27:36.527 回答