0

.htaccess file

 RewriteEngine On
 RewriteRule ^/?([a-z]+)/([a-z]+)/market/(?!.* (css|js|jpeg|jpg|JPG|png|PNG|svg|ttf|otf)).*$ external/market/index.php?param1=$1&param2=$2&param3=$3&param4=$4  [L,NC,QSA] 

When I use php to get the parameters, "param4" is missing. To be more precise its value is 0. The other three parameters work well. What can be the problem?

  • 1
    It looks like you are missing parentheses somewhere to capture the 4th regex group. It would also help if you could provide an example of URL to be matched by this regex. – Kate Jan 31 '20 at 15:21
  • The directive as written would result in a 500 error due to an "invalid flags argument" - because of the erroneous _space_ in the middle of the `RewriteRule` _pattern_. – MrWhite Mar 19 '20 at 17:36

1 Answers1

0

Solution: The static text "market" was not a parameter, so it could find it and it's value.

   RewriteRule ^/?([a-z]+)/([a-z]+)/market/(!?.*(css|js|jpeg|jpg|JPG|png|PNG|svg|ttf|otf)).*$ external/market/index.php?param1=$1&param2=$2&param3=$3 [L,NC,QSA]
  • "The static text "market" was not a parameter" - This doesn't appear to have changed in your answer? In your Q, you had `(?!` - which is a _negative lookahead_. This suggests that you wanted to avoid matching URLs with any of the given file exts (although the regex was not strictly correct in this regard). In your ans, you simply reversed the `?!` to become `!?` - this doesn't make much sense as it matches `!` _optionally_ - in other words it's most probably superfluous. However, this also reverses the logic of the later part of the regex - which is more likely to be significant. – MrWhite Mar 19 '20 at 17:59