Regular Expressions 101

Community Patterns

Community Library Entry

0

Regular Expression
PCRE2 (PHP >=7.3)

/
^(?<m>[^\?]+)\?(?:.*)?
/
gm

Description

Regular expression used to get the encoded URI portion of the $request_uri when unencoded $uri breaks a reverse proxy.

map $request_uri $request_uri_no_qs {
  "~^(?<m>[^\?]+)\?(?:.*)?"   $m;
  default                     $request_uri;
}
Submitted by jpatton@gmail.com - a year ago