我试图用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)。我的问题是如何修改规则或添加一个额外的规则来重写第二个参数(名称)?
发布于 2015-05-24 11:27:36
应该是这样的:
RewriteRule ^id/(\d+)/name/([^./]+)$ index.php?id=$1&name=$2 [NC,L]
RewriteRule ^id/(\d+)$ index.php?id=$1 [NC,L]发布于 2015-05-24 08:39:25
也许你可以试试这个:
# 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]https://stackoverflow.com/questions/30421414
复制相似问题