# Assets Directory - Static Files Only
# Allow CSS, JS, images, fonts - Block executable files

<IfModule mod_rewrite.c>
    RewriteEngine On

    # Block .php extension
    RewriteCond %{THE_REQUEST} \.php [NC]
    RewriteRule .* - [F,L]

    # Block executable files
    RewriteCond %{REQUEST_URI} \.(php|phtml|pl|py|jsp|asp|aspx|shtml|sh|cgi|exe|bat|com)$ [NC]
    RewriteRule .* - [F,L]
</IfModule>

# Disable PHP execution
<IfModule mod_php7.c>
    php_flag engine off
</IfModule>

# Block PHP files
<FilesMatch "\.php$">
    Order Allow,Deny
    Deny from all
</FilesMatch>

# Only allow safe static files
<FilesMatch "\.(css|js|jpg|jpeg|png|gif|svg|woff|woff2|ttf|eot|otf|ico)$">
    Order Allow,Deny
    Allow from all
</FilesMatch>

# Caching for static assets
<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType text/css "access plus 1 year"
    ExpiresByType application/javascript "access plus 1 year"
    ExpiresByType image/jpeg "access plus 1 year"
    ExpiresByType image/png "access plus 1 year"
    ExpiresByType image/gif "access plus 1 year"
    ExpiresByType image/svg+xml "access plus 1 year"
    ExpiresByType font/woff "access plus 1 year"
    ExpiresByType font/woff2 "access plus 1 year"
    ExpiresByType application/font-woff "access plus 1 year"
    ExpiresByType application/font-woff2 "access plus 1 year"
</IfModule>

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

# Security headers
<IfModule mod_headers.c>
    Header set X-Content-Type-Options "nosniff"

    # CORS for assets (if needed from different domain)
    # Header set Access-Control-Allow-Origin "*"
</IfModule>

# No directory listing
Options -Indexes -ExecCGI

# Block hidden files
<FilesMatch "^\.">
    Order Allow,Deny
    Deny from all
</FilesMatch>
