# Smart CDN Downloader - .htaccess

Options -Indexes
Options -ExecCGI

# Security headers
Header always set X-Content-Type-Options "nosniff"
Header always set X-Frame-Options "SAMEORIGIN"
Header always set X-XSS-Protection "1; mode=block"
Header always set Referrer-Policy "strict-origin-when-cross-origin"

# PHP settings
php_value upload_max_filesize 10M
php_value post_max_size 10M
php_value memory_limit 256M
php_value max_execution_time 300
php_value max_input_time 300

# API routing
RewriteEngine On

# Route /api/download to app/api.php?action=download
RewriteRule ^api/download$ app/api.php?action=download [QSA,L]
RewriteRule ^api/analyze$  app/api.php?action=analyze  [QSA,L]
RewriteRule ^api/history$  app/api.php?action=history  [QSA,L]
RewriteRule ^api/status$   app/api.php?action=status   [QSA,L]

# Block direct access to PHP files in sensitive folders
RewriteRule ^config/.*\.php$ - [F,L]
RewriteRule ^includes/.*\.php$ - [F,L]

# Allow storage videos to be served
RewriteRule ^storage/videos/(.*)$ storage/videos/$1 [L]

# Deny access to hidden files
<FilesMatch "^\.">
  Order allow,deny
  Deny from all
</FilesMatch>

# MIME types
AddType video/mp4  .mp4
AddType video/webm .webm
AddType video/ogg  .ogv
