Skip to content

Instantly share code, notes, and snippets.

@desawarna
Created August 21, 2025 05:56
Show Gist options
  • Save desawarna/39310bfaafbf63e5d594c2b19acf432d to your computer and use it in GitHub Desktop.
Save desawarna/39310bfaafbf63e5d594c2b19acf432d to your computer and use it in GitHub Desktop.
httaccess
# redirect all http to https
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Block Bot
RewriteEngine On RewriteCond %{HTTP_USER_AGENT} ^.*(Baiduspider|HTTrack|Yandex|AhrefsBot|Baiduspider|DuckDuckBot|Ezooms|MJ12bot|YandexBot|Google|TikTok|Bytedance|Semrush|Bing|BabbarTech|Commoncrawl|Neilpatel|Ais|Aioseo|Seoptimer).*$ [NC] RewriteRule .* - [F,L]
# Block URL Buruk
SetEnvIfNoCase Referer "google.com" bad_referer Order Allow,Deny Allow from ALL Deny from env=bad_referer
SetEnvIfNoCase Referer "duckduckgo.com" bad_referer Order Allow,Deny Allow from ALL Deny from env=bad_referer
SetEnvIfNoCase Referer "klaviyo.com" bad_referer Order Allow,Deny Allow from ALL Deny from env=bad_referer
SetEnvIfNoCase Referer "squarespace.com" bad_referer Order Allow,Deny Allow from ALL Deny from env=bad_referer
SetEnvIfNoCase Referer "tiktok.com" bad_referer Order Allow,Deny Allow from ALL Deny from env=bad_referer
SetEnvIfNoCase Referer "moz.com" bad_referer Order Allow,Deny Allow from ALL Deny from env=bad_referer
SetEnvIfNoCase Referer "opensiteexplorer.org" bad_referer Order Allow,Deny Allow from ALL Deny from env=bad_referer
SetEnvIfNoCase Referer "bytedance.com" bad_referer Order Allow,Deny Allow from ALL Deny from env=bad_referer
SetEnvIfNoCase Referer "semrush.com" bad_referer Order Allow,Deny Allow from ALL Deny from env=bad_referer
SetEnvIfNoCase Referer "bing.com" bad_referer Order Allow,Deny Allow from ALL Deny from env=bad_referer
SetEnvIfNoCase Referer "yahoo.com" bad_referer Order Allow,Deny Allow from ALL Deny from env=bad_referer
SetEnvIfNoCase Referer "babbar.tech" bad_referer Order Allow,Deny Allow from ALL Deny from env=bad_referer
SetEnvIfNoCase Referer "commoncrawl.org" bad_referer Order Allow,Deny Allow from ALL Deny from env=bad_referer
SetEnvIfNoCase Referer "neilpatel.com" bad_referer Order Allow,Deny Allow from ALL Deny from env=bad_referer
SetEnvIfNoCase Referer "aioseo.com" bad_referer Order Allow,Deny Allow from ALL Deny from env=bad_referer
SetEnvIfNoCase Referer "ahrefs.com" bad_referer Order Allow,Deny Allow from ALL Deny from env=bad_referer
SetEnvIfNoCase Referer "seoptimer.com" bad_referer Order Allow,Deny Allow from ALL Deny from env=bad_referer
# Apache/Senayan settings:
# by Hendro Wicaksono
# Protect files and directories from prying eyes.
<Files ~ "\.(png|jpe?g|gif)$">
Header set X-Robots-Tag "noindex"
</Files>
<FilesMatch "\.(engine|att|inc|info|install|module|profile|test|po|sh|.*inc.php|.*sql|theme|tpl(\.php)?|xtmpl|svn-base)$|^(code-style\.pl|Entries.*|Repository|Root|Tag|Template|all-wcprops|entries|format)$">
Order allow,deny
</FilesMatch>
<IfModule mod_rewrite.c>
RewriteEngine On
# Protect hidden directory from vulnerability scanner
RewriteRule (^|/)\.([^/]+)(/|$) - [L,F]
RewriteRule (^|/)([^/]+)~(/|$) - [L,F]
</IfModule>
# Don't show directory listings for URLs which map to a directory.
Options -Indexes
# Follow symbolic links in this directory.
# Options +FollowSymLinks
Options +SymLinksIfOwnerMatch
# Force simple error message for requests for non-existent favicon.ico.
<Files favicon.ico>
# There is no end quote below, for compatibility with Apache 1.3.
ErrorDocument 404 "The requested file favicon.ico was not found.
</Files>
# Set the default handler.
DirectoryIndex index.php
# Add XSS Protection and ClickJacking Attack
<IfModule mod_headers.c>
Header set X-XSS-Protection "1; mode=block"
Header always set X-Frame-Options SAMEORIGIN
</IfModule>
<Files 403.shtml>
order allow,deny
allow from all
</Files>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment