: To redirect a request for /something%26else (or /something&else, since the ampersand does not need to be escaped in the URL-path) to /something%2526else (ie. /something%26else when decoded)
To redirect a request for /something%26else (or /something&else, since the ampersand does not need to be escaped in the URL-path) to /something%2526else (ie. /something%26else when decoded) then you could do something like:
RewriteRule ^(something)&(else)$ /%26 [R,L]
The RewriteRule pattern matches against the %-decoded URL-path (ie. &, not %26). So you should simply specify & (ampersand) literally.
The % (percent) in the RewriteRule substitution needs to be backslash escaped in order to represent a literal %, otherwise it's going to be seen as a backreference to the last matched CondPattern, and there isn't any, so %2 would otherwise becomes an empty string!
Without the NE (noescape) flag, mod_rewrite will automatically encode the substitution URL, which is actually what we want in this instance: %26 gets encoded as %2526. (Which, when decoded, is seen as a literal %26.)
Alternatively, you could use the NE flag (that danlefree mentions) and then manually encode the substitution:
RewriteRule ^(something)&(else)$ /%2526 [R,L,NE]
More posts by @Jamie184
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.