开发者

Mod_Rewrite - how to modify so that all characters are removed?

I have this rewrite condion and rule which when a question mark is encountered in the query string removes everything after it. It works well for query strings like this:

?route=product​/product&a开发者_JS百科mp;​product_id=158?​ax13g76h

it returns this:

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

Which is what i want. However if the query string has more than 1 question mark such as:

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

It returns:

?route=product​/product&​product_id=158%3f123

This is the condition and rule, can anyone see why this is doing this when another question mark is encountered and how i can fix it so that everything after (and including) the question mark is removed?

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

Many Thanks

Pjn


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

note (.+?)

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜