Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [.htaccess] Problem z blokowaniem robotów
Przekras
post 11.01.2016, 22:30:28
Post #1





Grupa: Zarejestrowani
Postów: 6
Pomógł: 0
Dołączył: 24.06.2014

Ostrzeżenie: (0%)
-----


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):

  1. RewriteEngine On
  2. RewriteCond %{HTTP_HOST} ^strona.com$ [NC]
  3. RewriteRule ^(.*)$ http://www.strona.com/$1 [R=301,L]
  4. RewriteBase /
  5. RewriteCond %{REQUEST_URI} ^/index.php$
  6. RewriteCond %{QUERY_STRING} ^$
  7. RewriteRule ^(.*)$ http://www.strona.com/$ [R=301,L]
  8. RewriteRule ^rss.xml$ /rss.php [L]
  9. RewriteRule ^sitemap.xml$ /sitemap.php [L]
  10. RewriteRule ^([a-zA-Z0-9-]+)/$ http://%{HTTP_HOST}/$1 [R=301]
  11. RewriteRule ^site-([0-9]+)$ index.php?page=$1 [L,NC]
  12. RewriteRule ^([a-z-]+)$ index.php?aba=$1 [L,NC]
  13. RewriteRule ^([a-z-]+)/([a-zA-Z0-9-]+)/$ http://%{HTTP_HOST}/$1/$2 [R=301]
  14. RewriteRule ^([a-z-]+)/site-([0-9]+)$ index.php?aba=$1&page=$2 [L,NC]
  15. RewriteRule ^([a-z-]+)/([0-9]+)/([^*]+)/$ http://%{HTTP_HOST}/$1/$2/$3 [R=301]
  16. RewriteRule ^([a-z-]+)/([0-9]+)/([^*]+)$ index.php?aba=$1&id=$2&titleurl=$3 [L,NC]
  17. RewriteRule ^([a-z-]+)/([a-zA-Z0-9-]+)/([a-z-]+)/([a-zA-Z0-9-]+)/$ http://%{HTTP_HOST}/$1/$2/$3/$4 [R=301]
  18. RewriteRule ^([a-z-]+)/([a-zA-Z0-9-]+)/([a-z-]+)/site-([0-9]+)$ index.php?aba=$1&category=$2&titleurl=$3&page=$4 [L,NC]
  19. ErrorDocument 404 http://www.strona.com/
  20. ErrorDocument 403 http://www.strona.com/


Zmieniłem na taki:

  1. RewriteEngine On
  2. RewriteCond %{HTTP_HOST} ^strona.com$ [NC]
  3. RewriteRule ^(.*)$ http://www.strona.com/$1 [R=301,L]
  4. RewriteBase /
  5. RewriteCond %{REQUEST_URI} ^/index.php$
  6. RewriteCond %{QUERY_STRING} ^$
  7. RewriteRule ^(.*)$ http://www.strona.com/$ [R=301,L]
  8. RewriteRule ^rss.xml$ /rss.php [L]
  9. RewriteRule ^sitemap.xml$ /sitemap.php [L]
  10. RewriteRule ^([a-zA-Z0-9-]+)/$ http://%{HTTP_HOST}/$1 [R=301]
  11. RewriteRule ^site-([0-9]+)$ index.php?page=$1 [L,NC]
  12. RewriteRule ^([a-z-]+)$ index.php?aba=$1 [L,NC]
  13. RewriteRule ^([a-z-]+)/([a-zA-Z0-9-]+)/$ http://%{HTTP_HOST}/$1/$2 [R=301]
  14. RewriteRule ^([a-z-]+)/site-([0-9]+)$ index.php?aba=$1&page=$2 [L,NC]
  15. RewriteRule ^([a-z-]+)/([0-9]+)/([^*]+)/$ http://%{HTTP_HOST}/$1/$2/$3 [R=301]
  16. RewriteRule ^([a-z-]+)/([0-9]+)/([^*]+)$ index.php?aba=$1&id=$2&titleurl=$3 [L,NC]
  17. RewriteRule ^([a-z-]+)/([a-zA-Z0-9-]+)/([a-z-]+)/([a-zA-Z0-9-]+)/$ http://%{HTTP_HOST}/$1/$2/$3/$4 [R=301]
  18. RewriteRule ^([a-z-]+)/([a-zA-Z0-9-]+)/([a-z-]+)/site-([0-9]+)$ index.php?aba=$1&category=$2&titleurl=$3&page=$4 [L,NC]
  19. ## SITE REFERRER BANNING
  20. RewriteCond %{HTTP_REFERER} Traffic2cash.xyz [NC,OR]
  21. RewriteCond %{HTTP_REFERER} Share-buttons.xyz [NC]
  22. RewriteRule .* - [F]
  23. ## Bad bot
  24. SetEnvIfNoCase User-Agent "abot" bad_bot
  25. SetEnvIfNoCase User-Agent "AhrefsBot" bad_bot
  26. SetEnvIfNoCase User-Agent "aipbot" bad_bot
  27. SetEnvIfNoCase User-Agent "asterias" bad_bot
  28. SetEnvIfNoCase User-Agent "bingbot" bad_bot
  29. SetEnvIfNoCase User-Agent "EI" bad_bot
  30. SetEnvIfNoCase User-Agent "Blogshares Spiders" bad_bot
  31. SetEnvIfNoCase User-Agent "Board Bot" bad_bot
  32. SetEnvIfNoCase User-Agent "Board Bot" bad_bot
  33. SetEnvIfNoCase User-Agent "Convera" bad_bot
  34. SetEnvIfNoCase User-Agent "ConveraMultiMediaCrawler" bad_bot
  35. SetEnvIfNoCase User-Agent "c-spider" bad_bot
  36. SetEnvIfNoCase User-Agent "Yandex" bad_bot
  37. SetEnvIfNoCase User-Agent "YandexBot" bad_bot
  38. SetEnvIfNoCase User-Agent "zerxbot" bad_bot
  39. # Apache < 2.4
  40. <IfModule !mod_authz_core.c>
  41. <Limit GET POST>
  42. Order allow,deny
  43. Allow from all
  44. Deny from env=bad_bot
  45. </Limit>
  46. </IfModule>
  47. # Apache >= 2.4
  48. <IfModule mod_authz_core.c>
  49. <Limit GET POST>
  50. <RequireAll>
  51. Require all granted
  52. Require not env bad_bot
  53. </RequireAll>
  54. </Limit>
  55. </IfModule>
  56. ErrorDocument 404 http://www.strona.com/
  57. ErrorDocument 403 http://www.strona.com/


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
Go to the top of the page
+Quote Post
darko
post 11.01.2016, 23:05:56
Post #2





Grupa: Zarejestrowani
Postów: 2 885
Pomógł: 463
Dołączył: 3.10.2009
Skąd: Wrocław

Ostrzeżenie: (0%)
-----


W osobnym pliku tekstowym o nazwie robots.txt wpisz:

User-agent: *
Disallow: /

Co do wydajności to się nie wypowiem.
Źródło: http://www.robotstxt.org/robotstxt.html

Ten post edytował darko 11.01.2016, 23:06:48


--------------------
Nie pomagam na pw, tylko forum.
Go to the top of the page
+Quote Post
Przekras
post 11.01.2016, 23:17:56
Post #3





Grupa: Zarejestrowani
Postów: 6
Pomógł: 0
Dołączył: 24.06.2014

Ostrzeżenie: (0%)
-----


Cytat(darko @ 11.01.2016, 23:05:56 ) *
W osobnym pliku tekstowym o nazwie robots.txt wpisz:

User-agent: *
Disallow: /

Co do wydajności to się nie wypowiem.
Źródło: http://www.robotstxt.org/robotstxt.html

Chcę zablokować dostęp tylko niektórych robotów i zrobić to przez .htaccess, bo niektóre roboty nie zwracają uwagi na robots.txt
Go to the top of the page
+Quote Post
darko
post 12.01.2016, 12:18:58
Post #4





Grupa: Zarejestrowani
Postów: 2 885
Pomógł: 463
Dołączył: 3.10.2009
Skąd: Wrocław

Ostrzeżenie: (0%)
-----


Zerknij tutaj: http://en.linuxreviews.org/HOWTO_stop_auto...using_.htaccess


--------------------
Nie pomagam na pw, tylko forum.
Go to the top of the page
+Quote Post
Przekras
post 12.01.2016, 23:18:32
Post #5





Grupa: Zarejestrowani
Postów: 6
Pomógł: 0
Dołączył: 24.06.2014

Ostrzeżenie: (0%)
-----


Dzisiaj sprawdziłem funkcją "mail" czy blokada w .htaccess działa, tzn przy każdym wejściu na stronę wysyłało mi maila z informacją o User_Agent, i jednak blokada w .htaccess działa. Mimo iż bot nie pobiera zasobów strony, to jest pokazywany w logach, a do pliku index.php już się nie dostaje o czym nie wiedziałem. Także problem rozwiązany, dzięki za pomoc darko

Ten post edytował Przekras 12.01.2016, 23:21:13
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 19.04.2024 - 05:00