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. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1563,16 +1563,20 @@ generate_report() {
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "# User-Agent blocking (add to .htaccess):"
|
||||
echo "SetEnvIfNoCase User-Agent \"nikto|nmap|masscan|sqlmap|havij\" bad_bot"
|
||||
echo "SetEnvIfNoCase User-Agent \"acunetix|nessus|burp|metasploit\" bad_bot"
|
||||
echo "# cPanel User-Agent blocking (add to /etc/apache2/conf.d/includes/pre_main_global.conf):"
|
||||
echo ""
|
||||
echo "# Optional: Block aggressive SEO bots"
|
||||
echo "# SetEnvIfNoCase User-Agent \"AhrefsBot|SemrushBot|MJ12bot|DotBot\" bad_bot"
|
||||
echo "<IfModule mod_rewrite.c>"
|
||||
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 "Order Allow,Deny"
|
||||
echo "Allow from all"
|
||||
echo "Deny from env=bad_bot"
|
||||
echo "# Optional: Block aggressive SEO bots (uncomment to enable)"
|
||||
echo "# <IfModule mod_rewrite.c>"
|
||||
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 "# CSF/iptables format:"
|
||||
|
||||
Reference in New Issue
Block a user