簡體   English   中英

多個查詢字符串參數的ISAPI重寫規則

[英]ISAPI Rewrite Rule For Multiple Query String Parameters

我正在嘗試使用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)。 我的問題是如何修改規則或添加額外的規則以重寫第二個參數(名稱)?

也許您可以嘗試以下方法:

# 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]

應該是這樣的:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM