If it’s important for an application running behind a proxy that all URL characters reach the application unchanged, then unfortunately, the inbound request redirection configured via My Zone (mod_proxy) is not suitable for this purpose, because it makes certain modifications to the URL before passing it to the application.
For example, some characters are re-encoded into their hexadecimal equivalents.
Characters such as “#”, “&”, and “?” are transformed into “%23”, “%26”, and “%3F”, respectively.
This, in turn, makes it quite complicated to use applications such as Thumbor. Although in theory the nocanon keyword could help when using mod_proxy, unfortunately My Zone does not support this option.
RewriteCond "%{THE_REQUEST}" "^[A-Z]+\ /([^?\ ]+)/?"
RewriteRule "^/(.*)" "http://127.0.157.196:8888/%1" [P,NE]
127.0.157.196 and 8888 must be replaced with the correct values (you can find the correct loopback IP address either in the My Zone control panel under Webhosting → System information, or by running the command vs-loopback-ip -4 in the shell).
The NE flag in the Rewrite rule ensures that no modifications are made to the URL or parameters passed to the application.
https://httpd.apache.org/docs/2.4/rewrite/flags.html#flag_ne
RewriteCond explained
RewriteCond "%{THE_REQUEST}" "^[A-Z]+\ /([^?\ ]+)/?"
This is the condition under which the rule is applied.
Here, a special variable %{THE_REQUEST}, is used — it contains the browser’s original HTTP request line, for example:
GET /images/foo.jpg?size=large HTTP/1.1
Explanation of the regular expression(regexp) ^[A-Z]+\ /([^?\ ]+)/?:
-
^[A-Z]+— matches the HTTP method (e.gGET,POST,HEADetc) -
\ /— a space followed by a slash (the way every URL begins) -
([^?\ ]+)— captures all characters up to the first?(query parameters) or space.
In other words, it captures only the “clean path” part of the URL, without the query string. -
/?— allows for one optional trailing slash at the end.