2015-05-24 75 views
0

我想用2个查询字符串参数使用HeliconTech ISAPI_Rewrite版本3重写一个URL。我可以用1个参数重写URL,但是我找不出规则(S)改写2.ISAPI重写多个查询字符串参数的规则

原始地址:

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

回答

0

应该是这样的:

RewriteRule ^id/(\d+)/name/([^./]+)$ index.php?id=$1&name=$2 [NC,L] 
RewriteRule ^id/(\d+)$ index.php?id=$1 [NC,L] 
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] 
相关问题