# Disable Directory Indexing
Options -Indexes

# Set the Default Index File
DirectoryIndex index.php index.html

# Enable Rewrite Engine for URL Rewriting (if needed)
RewriteEngine On

# Example to ensure /admin uses the correct rules
RewriteCond %{REQUEST_URI} ^/admin [NC]
RewriteRule ^ - [L]

# Handle 404 Errors (Optional)
ErrorDocument 404 /404.html

# Block access to sensitive files
<FilesMatch "\.(htaccess|htpasswd|ini|log|txt)$">
    Order Allow,Deny
    Deny from all
</FilesMatch>

# Protect against common exploits
<IfModule mod_rewrite.c>
    RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
    RewriteCond %{QUERY_STRING} (\<|%3C).*iframe.*(\>|%3E) [NC,OR]
    RewriteCond %{QUERY_STRING} (\<|%3C).*object.*(\>|%3E) [NC,OR]
    RewriteCond %{QUERY_STRING} base64_encode.*\(.*\) [NC,OR]
    RewriteCond %{QUERY_STRING} (\<|%3C).*applet.*(\>|%3E) [NC,OR]
    RewriteCond %{QUERY_STRING} (\<|%3C).*embed.*(\>|%3E) [NC,OR]
    RewriteCond %{QUERY_STRING} (\<|%3C).*frame.*(\>|%3E) [NC,OR]
    RewriteCond %{QUERY_STRING} (\<|%3C).*form.*(\>|%3E) [NC,OR]
    RewriteCond %{QUERY_STRING} (\<|%3C).*style.*(\>|%3E) [NC,OR]
    RewriteRule .* - [F]
</IfModule>

# Deny access to .git and .svn folders
RedirectMatch 404 /\.git
RedirectMatch 404 /\.svn
