2016-02-26 47 views
1

我需要从以下阿帕奇重写URL上的查询字符串

/live/select?wt=json&group=true&group.field=content-type&fl=id,content-type&q=*:* 

重写URL到内容类型

/live/select?wt=json&group=true&group.field=content_type&fl=id,content-type&q=*:* 

只有第一次出现必须改变content_type。将hyper转换为下划线。

任何帮助,非常感谢。谢谢。

回答

1

您可以使用以下规则:

RewriteEngine on 

RewriteCond %{THE_REQUEST} /live/select\?wt=json&group=true&group\.field=content-type&fl=id,content-type&q=([^\s]+) [NC] 
RewriteRule^/live/select?wt=json&group=true&group.field=content-type&fl=id,content_type&q=%1 [NC,L,R] 
+0

感谢Starkeen。它的工作。但我需要一些额外的帮助,查询字符串可能会有一些双引号,并且它会被加密。例如 /live/select?wt=json&group=true&group.field=content-type&fl=id,content-type&q=type:" content“ 并且在这种情况下,其获得两次加密类型:%2522内容%2522 是无论如何要避免这种情况? –

+0

在您的规则** [NE,NC,L,R] **中使用NE无转义标志 – starkeen