Options -Indexes

<FilesMatch "^(database\.sql|\.htaccess|composer\.(json|lock)|.*\.(sql|log|ini|bak|env|conf))$">
    <IfModule mod_authz_core.c>
        Require all denied
    </IfModule>
    <IfModule !mod_authz_core.c>
        Order allow,deny
        Deny from all
    </IfModule>
</FilesMatch>

<IfModule mod_rewrite.c>
    RewriteEngine On

    # Always allow Let's Encrypt / Certbot SSL ACME challenges on VDS
    RewriteCond %{REQUEST_URI} ^/\.well-known/ [NC]
    RewriteRule ^ - [L]

    # Canonical www -> root domain redirect (preserving HTTPS/HTTP behind Cloudflare/proxy)
    RewriteCond %{HTTP_HOST} ^www\.xeva\.wtf$ [NC]
    RewriteCond %{HTTP:X-Forwarded-Proto} =https [OR]
    RewriteCond %{HTTPS} =on
    RewriteRule ^(.*)$ https://xeva.wtf/$1 [R=301,L]

    RewriteCond %{HTTP_HOST} ^www\.xeva\.wtf$ [NC]
    RewriteRule ^(.*)$ http://xeva.wtf/$1 [R=301,L]

    # Block common site-cloning / scraper bots
    RewriteCond %{HTTP_USER_AGENT} (HTTrack|WebCopier|WebZIP|Teleport|SiteSucker|Offline\ Explorer|BlackWidow|EmailCollector|Wget|Scrapy|python-requests|Go-http-client|curl|libwww-perl|MJ12bot|AhrefsBot|SemrushBot) [NC]
    RewriteRule .* - [F,L]
</IfModule>

<IfModule mod_headers.c>
    Header always set X-Frame-Options "SAMEORIGIN"
    Header always set X-Content-Type-Options "nosniff"
    Header always set Referrer-Policy "strict-origin-when-cross-origin"
</IfModule>
