# Matrimonial Backend Root Configuration
# Prevent directory listing
Options -Indexes

# Block direct access to environment files, git, package manager configs, database schemas, and admin scripts
<FilesMatch "(^\.env|^\.git|composer\.(json|lock)|\.sql$|\.md$|create_admin\.php)">
    <IfModule !mod_authz_core.c>
        Order deny,allow
        Deny from all
    </IfModule>
    <IfModule mod_authz_core.c>
        Require all denied
    </IfModule>
</FilesMatch>

# Block direct HTTP access to private backend directories and route web traffic to public/
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule ^(config|database|src|vendor|storage)/ - [F,L]
    RewriteRule ^$ public/ [L]
    RewriteRule (.*) public/$1 [L]
</IfModule>