'How to block No-user-agent browsers and browser with Tachiyomi user agent on my website using .htacess
tachiyomi keeps adding and removing user agents to get access to my website, so I want to add multiple user agents at the same time to get the things done
I know that I can use
RewriteCond %{HTTP_USER_AGENT} ^-?$
RewriteRule ^ - [F]
and
RewriteCond %{HTTP_USER_AGENT} Tachiyomi [NC]
RewriteRule ^ - [F]
but how to include both in the same?
Solution 1:[1]
Use the OR flag on the RewriteCond directive. For example:
RewriteCond %{HTTP_USER_AGENT} ^-?$ [OR]
RewriteCond %{HTTP_USER_AGENT} Tachiyomi [NC]
RewriteRule ^ - [F]
So the above rule is successful when the User-Agent string is either empty or a single hyphen OR contains "Tachiyomi" (case-insensitive).
Without the OR flag, the conditions are implicitly AND'd.
Multiple flags are separated by a comma (there must be no spaces). eg. [NC,OR]. The order of the flags do not matter.
NB: You must not use the OR flag on the very last condition, otherwise the rule will always be successful.
Reference:
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | MrWhite |
