Witam,
chciałem dodać do swojej strony blokowanie niektórych robotów, na jednej ze stron znalazłem listę robotów i dodałem kilka swoich(lista jest dłuższa niż na dole). Przed zmianami plik .htaccess wyglądał tak (wszystko dobrze działało, a czy wydajnie to nie wiem):
RewriteEngine On
RewriteCond %{HTTP_HOST} ^strona.com$ [NC]
RewriteBase /
RewriteCond %{REQUEST_URI} ^/index.php$
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^rss.xml$ /rss.php [L]
RewriteRule ^sitemap.xml$ /sitemap.php [L]
RewriteRule ^([a-zA-Z0-9-]+)/$ http://%{HTTP_HOST}/$1 [R=301]
RewriteRule ^site-([0-9]+)$ index.php?page=$1 [L,NC]
RewriteRule ^([a-z-]+)$ index.php?aba=$1 [L,NC]
RewriteRule ^([a-z-]+)/([a-zA-Z0-9-]+)/$ http://%{HTTP_HOST}/$1/$2 [R=301]
RewriteRule ^([a-z-]+)/site-([0-9]+)$ index.php?aba=$1&page=$2 [L,NC]
RewriteRule ^([a-z-]+)/([0-9]+)/([^*]+)/$ http://%{HTTP_HOST}/$1/$2/$3 [R=301]
RewriteRule ^([a-z-]+)/([0-9]+)/([^*]+)$ index.php?aba=$1&id=$2&titleurl=$3 [L,NC]
RewriteRule ^([a-z-]+)/([a-zA-Z0-9-]+)/([a-z-]+)/([a-zA-Z0-9-]+)/$ http://%{HTTP_HOST}/$1/$2/$3/$4 [R=301]
RewriteRule ^([a-z-]+)/([a-zA-Z0-9-]+)/([a-z-]+)/site-([0-9]+)$ index.php?aba=$1&category=$2&titleurl=$3&page=$4 [L,NC]
Zmieniłem na taki:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^strona.com$ [NC]
RewriteBase /
RewriteCond %{REQUEST_URI} ^/index.php$
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^rss.xml$ /rss.php [L]
RewriteRule ^sitemap.xml$ /sitemap.php [L]
RewriteRule ^([a-zA-Z0-9-]+)/$ http://%{HTTP_HOST}/$1 [R=301]
RewriteRule ^site-([0-9]+)$ index.php?page=$1 [L,NC]
RewriteRule ^([a-z-]+)$ index.php?aba=$1 [L,NC]
RewriteRule ^([a-z-]+)/([a-zA-Z0-9-]+)/$ http://%{HTTP_HOST}/$1/$2 [R=301]
RewriteRule ^([a-z-]+)/site-([0-9]+)$ index.php?aba=$1&page=$2 [L,NC]
RewriteRule ^([a-z-]+)/([0-9]+)/([^*]+)/$ http://%{HTTP_HOST}/$1/$2/$3 [R=301]
RewriteRule ^([a-z-]+)/([0-9]+)/([^*]+)$ index.php?aba=$1&id=$2&titleurl=$3 [L,NC]
RewriteRule ^([a-z-]+)/([a-zA-Z0-9-]+)/([a-z-]+)/([a-zA-Z0-9-]+)/$ http://%{HTTP_HOST}/$1/$2/$3/$4 [R=301]
RewriteRule ^([a-z-]+)/([a-zA-Z0-9-]+)/([a-z-]+)/site-([0-9]+)$ index.php?aba=$1&category=$2&titleurl=$3&page=$4 [L,NC]
## SITE REFERRER BANNING
RewriteCond %{HTTP_REFERER} Traffic2cash.xyz [NC,OR]
RewriteCond %{HTTP_REFERER} Share-buttons.xyz [NC]
RewriteRule .* - [F]
## Bad bot
SetEnvIfNoCase User-Agent "abot" bad_bot
SetEnvIfNoCase User-Agent "AhrefsBot" bad_bot
SetEnvIfNoCase User-Agent "aipbot" bad_bot
SetEnvIfNoCase User-Agent "asterias" bad_bot
SetEnvIfNoCase User-Agent "bingbot" bad_bot
SetEnvIfNoCase User-Agent "EI" bad_bot
SetEnvIfNoCase User-Agent "Blogshares Spiders" bad_bot
SetEnvIfNoCase User-Agent "Board Bot" bad_bot
SetEnvIfNoCase User-Agent "Board Bot" bad_bot
SetEnvIfNoCase User-Agent "Convera" bad_bot
SetEnvIfNoCase User-Agent "ConveraMultiMediaCrawler" bad_bot
SetEnvIfNoCase User-Agent "c-spider" bad_bot
SetEnvIfNoCase User-Agent "Yandex" bad_bot
SetEnvIfNoCase User-Agent "YandexBot" bad_bot
SetEnvIfNoCase User-Agent "zerxbot" bad_bot
# Apache < 2.4
<IfModule !mod_authz_core.c>
<Limit GET POST>
Order allow,deny
Allow from all
Deny from env=bad_bot
</Limit>
</IfModule>
# Apache >= 2.4
<IfModule mod_authz_core.c>
<Limit GET POST>
<RequireAll>
Require all granted
Require not env bad_bot
</RequireAll>
</Limit>
</IfModule>
Po zmianie roboty nie są blokowane (sprawdziłem w logach). Nie znam się za bardzo na plikach .htaccess, co mogę zmienić żeby to działało i miało dobrą wydajność?
Ten post edytował Przekras 11.01.2016, 22:35:42