<IfModule mod_ssl.c>
<VirtualHost *:443>
    ServerName apostas.jcwebsoftware.cloud

    # CORREÇÃO CRÍTICA: DocumentRoot deve apontar para /public
    # No Laravel, o DocumentRoot SEMPRE deve ser o diretório public
    DocumentRoot /var/www/html/apostas/public

    <Directory /var/www/html/apostas/public>
        AllowOverride All
        Require all granted
        Options -Indexes +FollowSymLinks
        
        # Garante que o mod_rewrite está funcionando
        <IfModule mod_rewrite.c>
            RewriteEngine On
            RewriteBase /
        </IfModule>
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/apostas_error.log
    CustomLog ${APACHE_LOG_DIR}/apostas_access.log combined

    RewriteEngine on

    # Some rewrite rules in this file were disabled on your HTTPS site,
    # because they have the potential to create redirection loops.

    # RewriteCond %{SERVER_NAME} =apostas.jcwebsoftware.cloud
    # RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]

    SSLCertificateFile /etc/letsencrypt/live/apostas.jcwebsoftware.cloud/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/apostas.jcwebsoftware.cloud/privkey.pem
    Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>

