I try to rewrite this URL. Group 4 is optional and looks until question mark. Group 5 must be captured even without g4 or slashes. Group 4 must be captured without Group 3.
https://www.example.de/prefix/group1/group2/group3-suffix/group4(optional)?group5
The Regex seems to work exactly as needed in most regex flavors, but in my .htaccess, group 5 is always empty.
My rewrite looks like this:
RewriteRule ^prefix/([^/]*)/([^/]*)/([^/]*)-suffix?/?((?:(?![?/]).)*)/?\??(.*)?/?$ /target.jsp?g1=$1&g2=$2&g3=$3&g4=$4&$5 [L]
Thank you for any help!