# Configuração do Apache para WhatsApp Offers System
# Copie este arquivo para /etc/apache2/sites-available/whatsapp-offers.conf

<VirtualHost *:80>
    ServerName localhost
    ServerAlias 192.168.10.17
    ServerAlias whatsapp-offers.local
    
    # Definir DocumentRoot para a pasta public
    DocumentRoot /var/www/whatsapp-offers-php/public
    
    # Configuração do diretório
    <Directory /var/www/whatsapp-offers-php/public>
        # Permitir acesso
        Options -Indexes +FollowSymLinks
        AllowOverride All
        Require all granted
        
        # Rewrite rules para roteamento
        <IfModule mod_rewrite.c>
            RewriteEngine On
            RewriteBase /
            
            # Não reescrever arquivos e diretórios reais
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteCond %{REQUEST_FILENAME} !-d
            
            # Reescrever para index.php
            RewriteRule ^(.*)$ index.php [QSA,L]
        </IfModule>
        
        # Se mod_rewrite não estiver disponível
        <IfModule !mod_rewrite.c>
            DirectoryIndex index.php index.html
        </IfModule>
    </Directory>
    
    # Configuração do PHP
    <FilesMatch "\.php$">
        SetHandler "proxy:unix:/run/php/php8.4-fpm.sock|fcgi://localhost"
    </FilesMatch>
    
    # Logs
    ErrorLog ${APACHE_LOG_DIR}/whatsapp-offers-error.log
    CustomLog ${APACHE_LOG_DIR}/whatsapp-offers-access.log combined
    
    # Segurança
    <FilesMatch "^(config|includes|logs)">
        Deny from all
    </FilesMatch>
    
    # Headers de segurança
    <IfModule mod_headers.c>
        Header set X-Content-Type-Options "nosniff"
        Header set X-Frame-Options "SAMEORIGIN"
        Header set X-XSS-Protection "1; mode=block"
    </IfModule>
</VirtualHost>
