

# ===================================================
# 1. WORDPRESS DEFAULT REWRITE RULES
# ===================================================
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]

# Add trailing slash to directories
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.+[^/])$ %{REQUEST_URI}/ [R=301,L]

# Redirect non-existing files to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress







# ===================================================
# 2. SECURITY HARDENING RULES
# ===================================================

# Disable Directory Browsing (কেউ যেন সরাসরি ফোল্ডার ওপেন করে ফাইল দেখতে না পারে)
Options -Indexes

# Block XML-RPC Access (Brute Force ও DDoS অ্যাটাক বন্ধ করার জন্য)
<Files xmlrpc.php>
    <IfModule mod_authz_core.c>
        Require all denied
    </IfModule>
    <IfModule !mod_authz_core.c>
        Order allow,deny
        Deny from all
    </IfModule>
</Files>

# Protect wp-config.php (ডাটাবেজ পাসওয়ার্ড ও কনফিগারেশন সুরক্ষিত রাখার জন্য)
<Files wp-config.php>
    <IfModule mod_authz_core.c>
        Require all denied
    </IfModule>
    <IfModule !mod_authz_core.c>
        Order allow,deny
        Deny from all
    </IfModule>
</Files>

# Protect .htaccess file itself (এই ফাইলটিকে সরাসরি ব্রাউজারে দেখা বন্ধ করতে)
<Files .htaccess>
    <IfModule mod_authz_core.c>
        Require all denied
    </IfModule>
    <IfModule !mod_authz_core.c>
        Order allow,deny
        Deny from all
    </IfModule>
</Files>

# Protect Sensitive Files (সেনসিটিভ ফাইল ও লগ রিড করা বন্ধ করা)
<FilesMatch "^(xmlrpc\.php|wp-config\.php|\.htaccess|readme\.html|license\.txt|wp-config-sample\.php)$">
    <IfModule mod_authz_core.c>
        Require all denied
    </IfModule>
    <IfModule !mod_authz_core.c>
        Order allow,deny
        Deny from all
    </IfModule>
</FilesMatch>



#BEGIN - Block access to debug.log
<Files debug.log>
Require all denied
</Files>
#END - Block access to debug.log