0

I frequently see the ?! combination in RewriteCond given in .htaccess files, like this:

RewriteCond %{REQUEST_URI} ^(?!/slim_demo/index\.php).*$

To my understanding, this directive checks if /slim_demo/index.php isn't part of the REQUEST_URI. Which is odd; what is the use of the ? at the very front, especially when it has no preceding character to match. The documentation says that ? "makes the match optional", but the only thing preceding the ? is the grouping bracket. Does it mean that ? is making grouping optional? Makes so sense!

What is the mystery?

ankush981
  • 4,595
  • 6
  • 42
  • 74

1 Answers1

1

Negative Lookahead After the Match: \d+(?!\d| dollars) Sample Match: 100 in 100 pesos Explanation: \d+ matches 100, then the negative lookahead (?! dollars) asserts that at that position in the string, what immediately follows is neither a digit nor the characters " dollars"