Forum Moderators: phranque
RewriteCond %{REQUEST_FILENAME} ^robots\.txt$
RewriteRule ^(.*)$ - [END]
deny from 118.193.41.43
Using the [END] flag terminates not only the current round of rewrite processing (like [L]) but also prevents any subsequent rewrite processing from occurring in per-directory (htaccess) context.
<Files robots.txt>
Require all granted
</Files>
For mod_rewrite, put a rule at the very beginning of your rewrite section that says RewriteRule robots.txt - [L]
(The anchored form ^robots.txt can and should be used if the rule is in a <Directory> section or htaccess.) User-Agent: *
Disallow: /
RewriteCond %{HTTP_USER_AGENT} ^.*(DataForSeoBot|AhrefsBot|wp_is_mobile|AppleBot|meerkatseo|LWP|AppleNewsBot|yacy|infotiger|amazonbot|YisouSpider|search.marginalia.nu|netvibes|Slurp|omgili|archive|AspiegelBot|AwarioSmartBot|axios|babbar|Baiduspider|basalsa|bbot|BcahiBot|BLEXBot|BluechipBacklinks|bsalsa|Bytespider|CCBot|Cliqzbot|curl|DaniBot|DataForSeoBot|daum.net|DotBot|EcoSearch|Exabot|eyemon|Flamingo_SearchEngine|GarlikCrawler|Gwene|Hatena|HTTrack|Jersey|Linespider|linkfluence|linkpad|magpie|mail.ru|MauiBot|MBCrawler|MJ12bot|naver|OpenNet.ru|PaperLiBot|PetalBot|picoFeed|Python|Qwantify|RyteBot|Seekport|SemrushBot|SentiBot|SerendeputyBot|serpstatbot|SeznamBot|Sogou|sogouspider|Studio|TkBot|trendiction|Wget|Yandex|zhanzhang|zoominfobot).*$ [NC]
RewriteRule .* - [F,L]
It should work without the {^.*} before the ( and the {.*$} after the closing )The one at the front is especially undesirable, because it means the server goes through the entire UA and only then stops and says “Oh, whoops, I guess I was supposed to pick up that string along the way.”