简体   繁体   中英

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.

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]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM