Options -Indexes
DirectoryIndex index.php
ErrorDocument 404 /404.php

<IfModule mod_rewrite.c>
RewriteEngine On

# Send old-style .php links to the clean address (e.g. /pricing.php → /pricing)
RewriteCond %{THE_REQUEST} \s/([A-Za-z0-9_-]+)\.php[\s?] [NC]
RewriteCond %1 !^(index|webhook|install)$
RewriteRule ^ /%1 [R=301,L]

# Clean addresses: /pricing → pricing.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/$1.php -f
RewriteRule ^([A-Za-z0-9_-]+)/?$ $1.php [L]
</IfModule>

# Never serve private or helper files
<FilesMatch "(^\.|\.(sql|lock|log|md|sample\.php|bak)$|^composer\.)">
    <IfModule mod_authz_core.c>
        Require all denied
    </IfModule>
</FilesMatch>

# Cache images, video, CSS and JS (file names change when updated)
<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType image/webp "access plus 1 year"
    ExpiresByType image/png "access plus 1 year"
    ExpiresByType image/jpeg "access plus 1 year"
    ExpiresByType video/mp4 "access plus 1 year"
    ExpiresByType text/css "access plus 1 year"
    ExpiresByType application/javascript "access plus 1 year"
</IfModule>

<IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/html text/css application/javascript application/json image/svg+xml
</IfModule>
