<IfModule mod_rewrite.c>
    RewriteEngine On

    RewriteRule ^(?:app|vendor|migrations|tests|docs|docker|runtime|backups|storage)(?:/|$) - [F,L,NC]
    RewriteRule (^|/)\. - [F,L]
    RewriteRule ^(?!index\.php(?:/|$)|install\.php$|cron\.php$).*\.(?:php[0-9]?|phtml|phar)(?:/|$) - [F,L,NC]

    RewriteRule ^uploads/(.*)$ public/uploads/$1 [L,NC]

    RewriteRule ^themes/.*\.php$ - [F,L,NC]

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^ index.php [QSA,L]
</IfModule>

# 保护敏感文件
<FilesMatch "^(config\.php|composer\.(json|lock)|\.env)">
    <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>
    RewriteRule ^runtime/ - [F,L]
    RewriteRule ^(?:backups|storage)/ - [F,L,NC]
</IfModule>

Options -Indexes
