开发者

Apache mod_rewrite manipulate query string

How using mod_rewrite could i manipulate the query string variable?

e.g. i want the f开发者_C百科ollowing query string:

?route=product​/product&​product_id=158?​ax13g76h

rewritten to:

?route=product​/product&​product_id=158

Basically i only want to keep everything between the 2 question marks. As soon as the second question mark is hit everything after is removed

Is this possible?


For this case you can use this:

RewriteCond %{QUERY_STRING} route=product/product&product_id=(\d+).*
RewriteRule (.*) $1?route=product/product&product_id=%1

And for all other

RewriteCond %{QUERY_STRING} (.+)\?.*
RewriteRule (.*) /$1?%1 [L,R=301]
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜