J-S
J-S

Reputation: 85

Apache rewrite URL on querystring

I need to rewrite the URL from the following

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

to this

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

Only the first occurrence of the content-type has to be change to content_type. Converting the hyper to a underscore.

Any help is much appreciated. Thank you.

Upvotes: 1

Views: 46

Answers (1)

Amit Verma
Amit Verma

Reputation: 41219

You can use the following rule :

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]

Upvotes: 1

Related Questions