RewriteCond %{HTTP_USER_AGENT} Re-re Studio (+http://vip0.ru/) [NC, OR]
By default, the 2nd argument to the RewriteCond directive is a regular expression (regex), so any meta characters (eg. + and .) need to be properly escaped. But importantly, spaces are delimiters in Apache config files so these also need to be escaped, otherwise, the directive will be wholly invalid. On Apache, the above will result in a fatal error (500 Internal Server Error) due to "bad flag delimiters". On LiteSpeed, it will simply fail silently.
Spaces can be "escaped" by either:
- Precede the space with a backslash. eg.
\ in hello\ world
- Or, use a
\s shorthand character class to represent any white-space character. eg. hello\sworld.
- Or, enclose the entire argument in double-quotes. eg.
"hello world".
[NC, OR] - However, there should be no spaces in the flag delimiters argument. This should be [NC,OR] (no space).
So, the above could be written like this:
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} OnalyticaBot [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "Re-re Studio (\+http://vip0\.ru/)" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "^Mozilla/5\.0 (compatible; Seekport Crawler; http://seekport\.com/$" [NC]
RewriteRule ^ - [F]
The regex .* in the RewriteRule pattern can be simplified to just ^ (which is more efficient) and the L flag is not required when using F - it is implied.
If you want to match an entire user-agent string then you can use the = (lexicographical string comparison for equality) prefix operator (together with double-quotes) on the CondPattern to test for an exact match.
For example:
RewriteCond %{HTTP_USER_AGENT} "=This is the exact user-agent I want to block"
RewriteRule ^ - [F]
In the above example, the string This is the ... block is an ordinary string, not a regex.