Fix bot blocking recommendations to use cPanel mod_rewrite format
Changed User-Agent blocking output from old .htaccess SetEnvIfNoCase format to modern mod_rewrite format suitable for cPanel global config. New format: - File: /etc/apache2/conf.d/includes/pre_main_global.conf - Uses <IfModule mod_rewrite.c> with RewriteCond/RewriteRule - Returns 403 Forbidden [F,L] for bad bots - Case-insensitive matching [NC] - Properly formatted for cPanel best practices Also updated SEO bot blocking section to match format.
This commit is contained in:
@@ -1563,16 +1563,20 @@ generate_report() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "# User-Agent blocking (add to .htaccess):"
|
echo "# cPanel User-Agent blocking (add to /etc/apache2/conf.d/includes/pre_main_global.conf):"
|
||||||
echo "SetEnvIfNoCase User-Agent \"nikto|nmap|masscan|sqlmap|havij\" bad_bot"
|
|
||||||
echo "SetEnvIfNoCase User-Agent \"acunetix|nessus|burp|metasploit\" bad_bot"
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "# Optional: Block aggressive SEO bots"
|
echo "<IfModule mod_rewrite.c>"
|
||||||
echo "# SetEnvIfNoCase User-Agent \"AhrefsBot|SemrushBot|MJ12bot|DotBot\" bad_bot"
|
echo " RewriteEngine On"
|
||||||
|
echo " RewriteCond %{HTTP_USER_AGENT} \"(nikto|nmap|masscan|sqlmap|havij|acunetix|nessus|burp|metasploit)\" [NC]"
|
||||||
|
echo " RewriteRule ^ - [F,L]"
|
||||||
|
echo "</IfModule>"
|
||||||
echo ""
|
echo ""
|
||||||
echo "Order Allow,Deny"
|
echo "# Optional: Block aggressive SEO bots (uncomment to enable)"
|
||||||
echo "Allow from all"
|
echo "# <IfModule mod_rewrite.c>"
|
||||||
echo "Deny from env=bad_bot"
|
echo "# RewriteEngine On"
|
||||||
|
echo "# RewriteCond %{HTTP_USER_AGENT} \"(AhrefsBot|SemrushBot|MJ12bot|DotBot|Meta-ExternalAgent|Go-http-client)\" [NC]"
|
||||||
|
echo "# RewriteRule ^ - [F,L]"
|
||||||
|
echo "# </IfModule>"
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "# CSF/iptables format:"
|
echo "# CSF/iptables format:"
|
||||||
|
|||||||
Reference in New Issue
Block a user