2015-05-24 105 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]