This rule looks to match relative directory names on linux/unix systems, where directory names cannot have a . (dot) or file names must have a suffix with a . (dot), and directory names must have at least 1 byte and cannot contain dot or question marks, I think that was the intent of this rule
in fact, it matches absolutely everything : matching any non / followed by an optional / ..... and excluding . (dot) and ? (question mark) on the way.
Are you sure you want to filter something with this expression before running index.php ? Do you really need a filter which excludes only . and ? ? Please provide what type of string you want to match with your redirection rule (as per the site guidelines)
I think you might hit a simple backtracking problem
the general form ([^x]+x?)* makes sone NFA engines (based on Thompson ideas from the 70's) going nuts.
Assuming you want to process directory names like the following ones (without . not ? in the directory names)
abc abcd/fgh abcd/
The following rule might help with less severe backtracking
- / is not optional between directory elements,
- use non-grouping syntax when you do not need the corresponding backreferences.
((?:[^/.?]+/)*[^/.?]*)
Backtracking is then restricted to the last directory elements, and is not exponentially complex. This now depends on your regular expression engine.
You might wish to update it with a more secure range of bytes, like excluding null bytes, control bytes, spaces, take care about newlines and the interaction with $ and ^ by disabling multiline, and so on. This depends on your application in index.php
An other thing : inside a character class, . is a ".", ? is "?" , there is no need to escape them.