# Apache mod_rewrite rules for Survey Notifier PHP
RewriteEngine On
RewriteBase /

# Allow direct access to existing files and directories
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]

# Redirect all other requests to index.php
RewriteRule ^(.*)$ index.php [L,QSA]

# Security headers
<IfModule mod_headers.c>
    Header set X-Content-Type-Options "nosniff"
    Header set X-Frame-Options "DENY"
    Header set X-XSS-Protection "1; mode=block"
</IfModule>

# Disable directory listing
Options -Indexes

# Protect sensitive files
<FilesMatch "\.(env|db|sqlite|log)$">
    Order allow,deny
    Deny from all
</FilesMatch>

# PHP settings
<IfModule mod_php.c>
    php_value max_execution_time 300
    php_value memory_limit 256M
    php_value post_max_size 50M
    php_value upload_max_filesize 50M
</IfModule>