I added
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} /article/
RewriteRule ! ^article/\d+ redirect.php [L]
to .htaccess and got a .htaccess: RewriteRule: bad flag delimiters message. Reviewed the related questions here but they didn't help.
!prefix-operator is part of the argument and spaces are argument delimiters. In your first exampleredirect.phpconsequently gets interpreted as the 3rd (flags) argument, which is obviously invalid - hence the error. – MrWhite Nov 18 '22 at 13:02