rewrite and url decoding

大憨熊 提交于 2019-12-04 15:17:06

Hmm, try this:

RewriteRule ^(.*\%3F.*)\%26([^%]*)(\%3D)?(.*)$ $1&$2=$4 [N]
RewriteRule ^(.*)\%3F([^%]*)(\%3D)?(.*)$ $1?$2=$4 [R=301,L]

EDIT: I see you already tested for %3F... if that didn`t work, then something else might be up.

It is not an elegant solution, but after months, it is the only way I found.

Regular case

domain.tld/dir/file.php?id=UID&qty=NUM&...   (from old site structure)

is rewritten as

domain.tld/newfile.php?id=UID&qty=NUM&... [R=301,L]

So, for requests like

domain.tld/dir/file.php%3Fid%3DUID%26qty=NUM%26...   (from old site structure)

I perform

RewriteRule ^dir/file\.php(.*)$ script.php?qs=$1 [R,L]

This MUST be AFTER all directives that involves dir/file.php

Then I can handle the query string $_GET['qs'] in script.php

It may not apply to other situations that would enter into a loop or undesired results.

use [NE] flag in your RewriteRule

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!